PageSourceSearch

https://gicorp.co.kr/js/render.1791433977.js

js gicorp.co.kr collected 2026-10-08 04:40:24 UTC 648,006 bytes, 15,013 lines download raw bytes

1var isAosBlock = false;
2var isgalleryView = false;
3var pageLoad = true;
4var menuClickMove = false;
5
6function parseShoppingGradeSettings(settings) {
7	if (!settings) return {};
8	if (typeof settings === 'object') return settings;
9	if (typeof settings === 'string') {
10		try {
11			return JSON.parse(settings);
12		} catch (e) {
13			return {};
14		}
15	}
16	return {};
17}
18
19function normalizeShoppingGradeChmod(chmod) {
20	if (typeof chmod === 'string') {
21		try {
22			chmod = JSON.parse(chmod);
23		} catch (e) {
24			chmod = chmod ? chmod.split(',') : [];
25		}
26	}
27	return $.isArray(chmod) ? $.map(chmod, function(v) { return String(v); }) : [];
28}
29
30function isShoppingGradeAdminMember(member) {
31	return member && (member.check_adm == 1 || member.check_uadm == 1);
32}
33
34function isShoppingGradeBlocked(product, blockSettings, property) {
35	var isAdmin = isShoppingGradeAdminMember(property && property.UMEMBER ? property.UMEMBER : null) || isShoppingGradeAdminPreview();
36	var isShoppingGradePlan = property && property.VALIDPLAN && property.VALIDTYPE == 'SM';
37	var settings = parseShoppingGradeSettings(blockSettings);
38	var parentSettings = parseShoppingGradeSettings(product && product.parent_elsettings);
39	var blockMemberOnly = settings.member_only == 'ON';
40	var parentMemberOnly = parentSettings.member_only == 'ON';
41	var chmod = [];
42	var userGrades = [];
43
44	if (blockMemberOnly) chmod = chmod.concat(normalizeShoppingGradeChmod(settings.gallery_page_chmod));
45	if (parentMemberOnly) chmod = chmod.concat(normalizeShoppingGradeChmod(parentSettings.gallery_page_chmod));
46	chmod = $.map(chmod, function(v) { return String(v); });
47
48	if (property && property.UMGRADE) {
49		if (typeof property.UMGRADE.seq != 'undefined' && property.UMGRADE.seq !== null) userGrades.push(String(property.UMGRADE.seq));
50		if (typeof property.UMGRADE.grade_id != 'undefined' && property.UMGRADE.grade_id !== null) userGrades.push(String(property.UMGRADE.grade_id));
51	}
52
53	if (isAdmin) return false;
54	if (!isShoppingGradePlan) return false;
55	if (product && product.shopping_grade_hidden == 'ON') return true;
56	if (!chmod.length) return false;
57
58	for (var i = 0; i < userGrades.length; i++) {
59		if ($.inArray(userGrades[i], chmod) > -1) return false;
60	}
61
62	return true;
63}
64
65function getShoppingGradeBlockedMessage(product) {
66	var msg = product && product.shopping_grade_hidden_msg ? product.shopping_grade_hidden_msg : '해당 등급 고객 전용 상품입니다.';
67	return normalizeShoppingGradeBlockedMessage(msg);
68}
69
70function normalizeShoppingGradeBlockedMessage(msg) {
71	if (!msg) return '해당 등급 고객 전용 상품입니다.';
72	msg = msg.replace(/,\s*/g, ' ');
73	return msg;
74}
75
76function isShoppingGradeEditorPreview() {
77	return property
78		&& property.PUBLISH === false
79		&& property.LOAD === 'RENDER'
80		&& property.VALIDTYPE === 'SM';
81}
82
83function isShoppingGradeAdminPreview() {
84	return isShoppingGradeEditorPreview()
85		&& property.UMEMBER
86		&& isShoppingGradeAdminMember(property.UMEMBER);
87}
88
89function hasShoppingGradeDiscount(grade) {
90	return grade && String(grade.discount_use) == '1' && Number(grade.discount_value || 0) > 0;
91}
92
93function getBestShoppingGradePreviewDiscountGrade(grades) {
94	var rateGrade = null,
95		rateValue = null,
96		fixedGrade = null,
97		fixedValue = null;
98
99	$.each(grades || [], function(i, grade) {
100		if(!hasShoppingGradeDiscount(grade)) return true;
101
102		var discountValue = Number(grade.discount_value || 0);
103		if(String(grade.discount_type) == '0') {
104			if(rateValue === null || discountValue > rateValue) {
105				rateValue = discountValue;
106				rateGrade = grade;
107			}
108		} else if(fixedValue === null || discountValue > fixedValue) {
109			fixedValue = discountValue;
110			fixedGrade = grade;
111		}
112	});
113
114	var selectedGrade = rateGrade || fixedGrade;
115	if(!selectedGrade) return null;
116
117	selectedGrade = $.extend({}, selectedGrade);
118	selectedGrade.__preview_ignore_min = 'Y';
119	return selectedGrade;
120}
121
122function getShoppingGradePreviewDiscountGrade(fallbackGrade) {
123	if (hasShoppingGradeDiscount(property && property.UMGRADE ? property.UMGRADE : null)) return property.UMGRADE;
124	if (!isShoppingGradeAdminPreview()) {
125		return (!$.isArray(fallbackGrade) && hasShoppingGradeDiscount(fallbackGrade)) ? fallbackGrade : null;
126	}
127
128	if ($.isArray(fallbackGrade)) {
129		return getBestShoppingGradePreviewDiscountGrade(fallbackGrade);
130	}
131
132	return hasShoppingGradeDiscount(fallbackGrade) ? $.extend({}, fallbackGrade, {__preview_ignore_min:'Y'}) : null;
133}
134
135function getShoppingGradeProductGradeOnOff(product) {
136	if(!product) return 'OFF';
137	if(typeof product.grade_onoff != 'undefined' && product.grade_onoff !== null && product.grade_onoff !== '') {
138		return product.grade_onoff == 'ON' ? 'ON' : 'OFF';
139	}
140
141	var settings = parseShoppingGradeSettings(product.gsettings);
142	return (typeof settings.grade_onoff != 'undefined' && settings.grade_onoff == 'ON') ? 'ON' : 'OFF';
143}
144
145function isShoppingGradeProductGradePriceEnabled(product) {
146	return getShoppingGradeProductGradeOnOff(product) == 'ON';
147}
148
149function calcShoppingGradeDisplayPrice(price, grade) {
150	if (!hasShoppingGradeDiscount(grade) || price <= 0) return null;
151	if (grade.__preview_ignore_min != 'Y' && price < Number(grade.discount_amount || 0)) return null;
152
153	var discountAmount = 0;
154	if (String(grade.discount_type) === '0') {
155		discountAmount = Math.floor(price * (Number(grade.discount_value || 0) / 100));
156		if (Number(grade.discount_max || 0) > 0 && discountAmount > Number(grade.discount_max || 0)) {
157			discountAmount = Number(grade.discount_max || 0);
158		}
159	} else {
160		discountAmount = Number(grade.discount_value || 0);
161	}
162
163	var gradePrice = price - discountAmount;
164	if (gradePrice < 0) gradePrice = 0;
165	return (discountAmount > 0 && gradePrice < price) ? gradePrice : null;
166}
167
168function isShoppingGradePriceHidden(item) {
169	return item && item.price_hidden == 'ON' && !isShoppingGradeAdminPreview();
170}
171var getRenderMenuSlug = function(name) {
172	return $.trim(String(name || ''))
173		.replace(/ /g, '-')
174		.replace(/\//g, '/')
175		.replace(/&/g, '&')
176		.replace(/\./g, '.')
177		.replace(/\+/g, '+')
178		.replace(/\(/g, '(')
179		.replace(/\)/g, ')');
180};
181
182var normalizeRenderMenuLinkPage = function(value) {
183	value = $.trim(String(value || ''));
184	try {
185		value = decodeURIComponent(value);
186	} catch(e) {}
187	value = value.replace(/^\/+/g, '');
188	if (value.indexOf('#') === 0) value = value.replace(/^#+/g, '');
189	else if (value.indexOf('#') > -1 && !/^https?:\/\//i.test(value)) value = value.split('#').pop();
190	value = value.split('?')[0].split(',')[0];
191	return getRenderMenuSlug(value);
192};
193
194var isRenderMenuPageLink = function(value, list) {
195	list = list || ((typeof property != 'undefined' && property.MENULIST) ? property.MENULIST : []);
196	return $.inArray(normalizeRenderMenuLinkPage(value), list) > -1;
197};
198
199var getRenderMenuPage = function(obj) {
200	if (!obj) return '';
201	return (typeof obj.page != 'undefined' && obj.page) ? obj.page : getRenderMenuSlug(obj.name);
202};
203
204var getRenderMenuUid = function(obj) {
205	if (!obj) return '';
206	return $.trim(String(obj.menu_uid || '')).replace(/[^A-Za-z0-9_-]/g, '').substr(0, 64);
207};
208
209var getRenderMenuUidMap = function(menu) {
210	var map = {};
211	var addMenuLink = function(level) {
212		$.each(level || [], function(i, obj) {
213			var menuUid = getRenderMenuUid(obj);
214			if (menuUid) map[menuUid] = obj;
215			if (obj.children && obj.children.length > 0) addMenuLink(obj.children);
216		});
217	};
218	addMenuLink(menu);
219	return map;
220};
221
222var getRenderMenuPageMap = function(menu) {
223	var map = {};
224	var addMenuLink = function(level) {
225		$.each(level || [], function(i, obj) {
226			map[normalizeRenderMenuLinkPage(getRenderMenuPage(obj))] = obj;
227			if (obj.children && obj.children.length > 0) addMenuLink(obj.children);
228		});
229	};
230	addMenuLink(menu);
231	return map;
232};
233
234var getRenderTabmenuEntryPolicy = function(menu, target) {
235	if (!target) return null;
236	var targetUid = getRenderMenuUid(target);
237	var targetPage = normalizeRenderMenuLinkPage(getRenderMenuPage(target));
238	var isSameMenu = function(item) {
239		var itemUid = getRenderMenuUid(item);
240		if (targetUid && itemUid) return targetUid == itemUid;
241		return normalizeRenderMenuLinkPage(getRenderMenuPage(item)) == targetPage;
242	};
243	var result = null;
244
245	$.each(menu || [], function(index, parent) {
246		if (!isSiteMenuTabmenuEnabled(parent)) return true;
247		var firstChild = null;
248		$.each(parent.children || [], function(childIndex, child) {
249			if (!child || child.display === 'off') return true;
250			firstChild = child;
251			return false;
252		});
253
254		if (isSameMenu(parent)) {
255			result = {role: 'parent', child: firstChild};
256			return false;
257		}
258		if (firstChild && isSameMenu(firstChild)) {
259			result = {role: 'default', child: firstChild};
260			return false;
261		}
262	});
263
264	return result;
265};
266
267var decodeRenderMenuLink = function(link) {
268	link = String(link || '');
269	try {
270		if (checkBase64Encode(decodeURIComponent(link))) return Base64.decode(decodeURIComponent(link));
271		if (checkBase64Encode(link)) return Base64.decode(link);
272	} catch(e) {}
273	return link;
274};
275
276var normalizeRenderMenuExternalUrl = function(link) {
277	link = decodeRenderMenuLink(link);
278	if (!/^(?:[a-z][a-z0-9+.-]*:|\/\/|\/|#)/i.test(link)
279		&& /^(?:[a-z0-9-]+\.)+[a-z]{2,}(?::[0-9]+)?(?:[\/?#].*)?$/i.test(link)) {
280		link = '//' + link;
281	}
282	return link;
283};
284
285var isRenderMenuPolicyEnabled = function() {
286	var settings = (typeof property != 'undefined' && property && property.SETTINGS) ? property.SETTINGS : {};
287	if (typeof settings == 'string') {
288		try { settings = JSON.parse(settings); } catch(e) { settings = {}; }
289	}
290	return Number(settings.menuPolicy || 0) === 1;
291};
292
293var usesRenderResolvedMenuPolicy = function() {
294	return isRenderMenuPolicyEnabled();
295};
296
297var resolveRenderMenuDestination = function(menu, source, requirePolicy) {
298	var uidMap = getRenderMenuUidMap(menu);
299	var pageMap = getRenderMenuPageMap(menu);
300	var visited = {};
301	var resolve = function(obj, depth, checkPolicy) {
302		if (!obj || depth >
302 20) return {type: 'invalid', value: ''};
303		var uid = getRenderMenuUid(obj);
304		var page = getRenderMenuPage(obj);
305		var visitKey = uid || page;
306		if (visited[visitKey]) return {type: 'cycle', value: ''};
307		visited[visitKey] = true;
308		var tabmenuEntry = getRenderTabmenuEntryPolicy(menu, obj);
309		if (tabmenuEntry) {
310			if (tabmenuEntry.role == 'parent' && tabmenuEntry.child) return resolve(tabmenuEntry.child, depth + 1, false);
311			return {type: 'page', value: page, menu: obj};
312		}
313
314		if (checkPolicy && !usesRenderResolvedMenuPolicy()) return {type: 'page', value: page, menu: obj};
315		var link = String(obj.link || '');
316		if (!link) {
317			if (isSiteMenuTabmenuEnabled(obj)) {
318				var children = $.isArray(obj.children) ? obj.children : [];
319				for (var i = 0; i < children.length; i++) {
320					if (children[i] && children[i].display !== 'off') return resolve(children[i], depth + 1, false);
321				}
322			}
323			return {type: 'page', value: page, menu: obj};
324		}
325		if (link == 'folder-menu') return {type: 'folder', value: '', menu: obj};
326		if (/^flink\@[0-9]+/i.test(link)) return {type: 'file', value: link.replace(/^flink\@/i, ''), menu: obj};
327		if (/^@/.test(link)) return {type: 'bookmark', value: link, menu: obj};
328
329		var target = (obj.link_uid && uidMap[obj.link_uid]) ? uidMap[obj.link_uid] : pageMap[normalizeRenderMenuLinkPage(link)];
330		if (target) return resolve(target, depth + 1, false);
331		if (obj.link_uid) return {type: 'invalid', value: '', menu: obj};
332		return {type: 'url', value: normalizeRenderMenuExternalUrl(link), menu: obj};
333	};
334	return resolve(source, 0, requirePolicy !== false);
335};
336
337var applyRenderMenuDestination = function($link, destination, one, view) {
338	if (!$link || !$link.length || !destination) return;
339	var hasUserLink = typeof $link.attr('data-user-link-id') != 'undefined';
340	if (destination.type != 'bookmark') $link.removeData('menu-bookmark-link');
341	$link.removeAttr('attr-bookmark attr-flink attr-folder');
342
343	var href = '';
344	if (destination.type == 'page') href = (typeof makeLinkUrl == 'function') ? makeLinkUrl(destination.value, one, view) : '/' + destination.value;
345	else if (destination.type == 'url') href = destination.value;
346	else if (destination.type == 'bookmark') {
347		if (/^@/.test(destination.value)) {
348			$link.data('menu-bookmark-link', destination.value);
349			$link.attr('href', 'javascript:;').attr('attr-bookmark', destination.value.substring(1));
350			resolveMenuBookmark(destination.value, property.SID, property.PUBLISH).done(function(bookmark) {
351				if ($link.data('menu-bookmark-link') !== destination.value) return;
352				applyRenderMenuDestination($link, {type: 'bookmark', value: bookmark.value}, one, view);
353			});
354			return;
355		}
356		href = (typeof makeLinkUrl == 'function') ? makeLinkUrl(destination.value, one, view) : '/' + destination.value;
357		$link.attr('attr-bookmark', String(destination.value).split('@').pop());
358	}
359	else if (destination.type == 'file') {
360		href = 'flink@' + destination.value;
361		$link.attr('attr-flink', destination.value);
362	} else if (destination.type == 'folder') {
363		href = 'javascript:;';
364		$link.attr('attr-folder', 'true');
365	}
366	if (!href) return;
367
368	$link.attr('href', href);
369	if (hasUserLink) {
370		if (destination.type == 'page') $link.attr('data-user-link', href);
371		else $link.removeAttr('data-user-link');
372	}
373	if (typeof $link.attr('data-href') != 'undefined') $link.attr('data-href', href);
374};
375
376var syncRenderSidemobileBannerDestination = function($option, destination, one, view) {
377	var link = '';
378	var href = '';
379	var linkType = '';
380	if (destination.type == 'page') {
381		link = destination.value;
382		href = (typeof makeLinkUrl == 'function') ? makeLinkUrl(destination.value, one, view) : '/' + destination.value;
383		linkType = 'link-menu';
384	} else if (destination.type == 'url') {
385		link = destination.value;
386		href = destination.value;
387		linkType = 'link-out';
388	} else if (destination.type == 'bookmark') {
389		link = '@' + String(destination.value).split('@').pop();
390		href = (typeof makeLinkUrl == 'function') ? makeLinkUrl(destination.value, one, view) : '/' + destination.value;
391		linkType = 'link-bookmark';
392	} else if (destination.type == 'file') {
393		link = 'flink@' + destination.value;
394		href = link;
395		linkType = 'link-file';
396	}
397
398	$option.attr({
399		'data-sidemobile-banner-link': link,
400		'data-sidemobile-banner-href': href,
401		'data-sidemobile-banner-link-type': linkType
402	});
403};
404
405var syncRenderShowcaseDestination = function($link, destination, one, view) {
406	var href = '';
407	var shlink = '';
408	$link.removeAttr('attr-link attr-bookmark attr-flink attr-folder');
409
410	if (destination.type == 'page') {
411		href = (typeof makeLinkUrl == 'function') ? makeLinkUrl(destination.value, one, view) : '/' + destination.value;
412		shlink = $link.hasClass('showcase-link') ? destination.value : href;
413	} else if (destination.type == 'url') {
414		href = destination.value;
415		shlink = destination.value;
416		$link.attr('attr-link', destination.value);
417	} else if (destination.type == 'bookmark') {
418		href = (typeof makeLinkUrl == 'function') ? makeLinkUrl(destination.value, one, view) : '/' + destination.value;
419		shlink = destination.value;
420		$link.attr('attr-bookmark', String(destination.value).split('@').pop());
421	} else if (destination.type == 'file') {
422		href = 'flink@' + destination.value;
423		shlink = href;
424		$link.attr('attr-flink', destination.value);
425	} else if (destination.type == 'folder') {
426		$link.attr('attr-folder', 'true');
427	}
428
429	if (typeof $link.attr('data-shlink') != 'undefined') $link.attr('data-shlink', shlink);
430	if (href && typeof $link.attr('href') != 'undefined') $link.attr('href', href);
431};
432
433var syncRenderUserLinksByMenuUid = function(menu, one, view) {
434	var linkMap = getRenderMenuUidMap(menu);
435	$('[data-user-link-id]').each(function() {
436		var $link = $(this);
437		var linkId = $link.attr('data-user-link-id');
438		if (!linkId || !linkMap[linkId]) return true;
439		applyRenderMenuDestination($link, resolveRenderMenuDestination(menu, linkMap[linkId]), one, view);
440	});
441	$('[data-menu-link-id]').each(function() {
442		var $link = $(this).is('a') ? $(this) : $(this).children('a').first();
443		var linkId = $(this).attr('data-menu-link-id') || $link.attr('data-menu-link-id');
444		if (!linkId || !linkMap[linkId]) return true;
445		if (!usesRenderResolvedMenuPolicy()) return true;
446		applyRenderMenuDestination($link, resolveRenderMenuDestination(menu, linkMap[linkId]), one, view);
447	});
448	$('.cl-tabmenu .tabmenu-btn[data-menu-uid]').each(function() {
449		var $link = $(this);
450		var linkId = $link.attr('data-menu-uid');
451		if (!linkId || !linkMap[linkId]) return true;
452		var destination = resolveRenderMenuDestination(menu, linkMap[linkId]);
453		applyRenderMenuDestination($link, destination, one, view);
454		if (destination.type == 'url' && destination.menu && destination.menu.ltarget == '_blank') $link.attr('target', '_blank');
455		else $link.removeAttr('target');
456	});
457	$('[data-sidemobile-banner-link-id]').each(function() {
458		var $option = $(this);
459		var linkId = $option.attr('data-sidemobile-banner-link-id');
460		if (!linkId || !linkMap[linkId]) return true;
461		var destination = resolveRenderMenuDestination(menu, linkMap[linkId]);
462		syncRenderSidemobileBannerDestination($option, destination, one, view);
463	});
464	$('[data-shlink-id]').each(function() {
465		var $link = $(this);
466		var linkId = $link.attr('data-shlink-id');
467		if (!linkId || !linkMap[linkId]) return true;
468		var destination = resolveRenderMenuDestination(menu, linkMap[linkId]);
469		syncRenderShowcaseDestination($link, destination, one, view);
470	});
471};
472
473var getRenderOnepagePageBlock = function(pageName, selector) {
474	pageName = String(pageName || '');
475	selector = selector || '.element[data-pagename]';
476
477	var $pageBlock = $(selector).filter(function() {
478		return $(this).attr('data-pagename') === pageName;
479	});
480	if ($pageBlock.length > 0) return $pageBlock;
481
482	var className = 'link-to-' + pageName;
483	return $('.element, .elem').filter(function() {
484		return String($(this).attr('class') || '').split(/\s+/).indexOf(className) > -1;
485	});
486};
487
488var getRenderTabmenuBlocksByPage = function(pageName) {
489	pageName = normalizeRenderMenuLinkPage(String(pageName || '').split(',')[0]);
490	if (!pageName) return $();
491
492	return $('.dsgn-body .cl-tabmenu, .tabmenu-sticky-rail .cl-tabmenu').filter(function() {
493		return $(this).find('.tabmenu-btn[data-page]').filter(function() {
494			return normalizeRenderMenuLinkPage($(this).attr('data-page') || '') 
494=== pageName;
495		}).length > 0;
496	});
497};
498
499var setRenderTabmenuLockPending = function(pageName, pending) {
500	getRenderTabmenuBlocksByPage(pageName).each(function() {
501		if (pending) {
502			this.style.setProperty('display', 'none', 'important');
503			$(this).attr('data-tabmenu-lock-pending', 'true');
504		} else if ($(this).attr('data-tabmenu-lock-pending') === 'true') {
505			this.style.removeProperty('display');
506			$(this).removeAttr('data-tabmenu-lock-pending');
507		}
508	});
509};
510
511var RENDER = {
512    init: function (property) {
513		var History = window.History; 
514		var b = property,
515			URI = (b.PUBLISH) ? '/' : '/render',
516			param = (b.PUBLISH) ? '/publish/true' : '',
517			selectEL = '',
518			galleryEL = new Object();
519		var CERT_USERID = '';
520		
521			this.b = b;
522			var initialHashPage = '';
523			if (b.ONE && location.hash) {
524				try {
525					initialHashPage = normalizeRenderMenuLinkPage(decodeURIComponent(location.hash.replace(/^#/, '')).split('@')[0]);
526				} catch(hashError) {}
527			}
528			var initialLockedTabmenuHashPage = '';
529			var hasInitialTabmenuPage = false,
530				initialTabmenuPageChanged = false;
531			$.each($.isArray(b.SMENU) ? b.SMENU : [], function(_, menu) {
532				if(!isSiteMenuTabmenuEnabled(menu)) return true;
533
534				var children = $.isArray(menu.children) ? menu.children : [],
535					defaultUid = getSiteMenuTabmenuDefaultUid(menu),
536					entryChild = null,
537					isCurrentChildPage = false;
538				$.each(children, function(_, child) {
539					if(!child || child.display === 'off') return true;
540					if(entryChild === null) entryChild = child;
541					if(String(getRenderMenuPage(child)) === String(b.PAGE || '')) isCurrentChildPage = true;
542					if(initialHashPage
543						&& normalizeRenderMenuLinkPage(getRenderMenuPage(child)) === initialHashPage
544						&& (child.lock || menu.lock)
545					) initialLockedTabmenuHashPage = getRenderMenuPage(child);
546					if(defaultUid && String(child.menu_uid || '') === defaultUid) {
547						entryChild = child;
548					}
549				});
550
551				var isCurrentParentPage = String(getRenderMenuPage(menu)) === String(b.PAGE || '');
552				// 멀티페이지에서는 현재 탭메뉴 그룹일 때만 초기 블럭을 다시 조회한다.
553				if(b.ONE || isCurrentParentPage || isCurrentChildPage) hasInitialTabmenuPage = true;
554				if(!b.ONE && isCurrentParentPage && entryChild) {
555					var entryPage = getRenderMenuPage(entryChild);
556					b.PAGE = entryPage;
557					b.MPAGE = entryPage;
558					initialTabmenuPageChanged = true;
559				}
560			});
561			if (b.ISLOCK == 'true') setRenderTabmenuLockPending(b.PAGE, true);
562			if (initialLockedTabmenuHashPage) setRenderTabmenuLockPending(initialLockedTabmenuHashPage, true);
563			var refreshInitialTabmenuPage = hasInitialTabmenuPage && !b.VIEW
564				&& (initialTabmenuPageChanged || $('.dsgn-body .tabmenu-auto-block, .dsgn-body .element[data-type="tabmenu"]').length === 0);
565			this.b.pageContent = {};
566			if(!refreshInitialTabmenuPage) this.b.pageContent[b.PAGE] = b.INITPAGE;
567			this.b.pageInitContent = {};
568			if(!refreshInitialTabmenuPage) this.b.pageInitContent[b.PAGE] = b.INITPAGE;
569			this.b.pageConf = {};
570			this.b.pageConf[b.PAGE] = b.PAGECONF || {
571				islock: b.ISLOCK,
572				overlay: b.HEADER,
573				pageScript: '',
574				meta: null,
575				og_others: null
576			};
577			this.b.pageBlocksType = {};
578			this.b.URL = URI;
579			this.b.param = param;
580			this.history = window.History;
581			this.b.MENULIST = [];
582			this.galleryEL = galleryEL;
583			this.b.certOpenChk = false;
584			_this = this;
585
586			var applyPageConf = function(data) {
587				if(!data) return true;
588				if(typeof data.url != 'undefined' && data.url) {
589					location.href = data.url;
590					return false;
591				}
592
593				if(typeof data.islock != 'undefined') b.ISLOCK = data.islock;
594				if(typeof data.overlay != 'undefined') b.HEADER = (data.overlay) ? true : false;
595
596				var isSidebar = $('.el-menu > header').hasClass('sidebar');
597				var isHeaderOldVer = !$.clnav.check();
598				if(isHeaderOldVer) {
599					if(b.HEADER && !b.VIEW && !isSidebar) {
600						$('.header-empty').css('height',0);
601						$('.header.el-menu').removeClass('fixed');
602						$('header.navbar').addClass('transparent');
603					} else {
604						$('header.navbar').removeClass('transparent');
605					}
606				}
607
608				if(typeof data.pageScript != 'undefined') {
609					$('#pageScript').remove();
610					if(data.pageScript) $('body').append(data.pageScript);
611				}
612				if(data.meta != null) {
613					$.each(data.meta, function(k,v) {
614						$('meta[name="' + k + '"]').attr('content',v);
615						if(k == 'title') {
616							$(document).prop('title', htmlspecialchars_decode(v));
617						}
618					});
619				}
620				if(data.og_others != null) {
621					$.each(data.og_others, function(ok,ov) {
622						var og_property = ok.replace(/\_\_/gi,':');
623						if(ov != '') {
624							if($('meta[property="' + og_property + '"]').length > 0) $('meta[property="' + og_property + '"]').attr('content',ov);
625							else $('meta[property^="og:"]').eq($('meta[property^="og:"]').length - 1).after('<meta property="' + og_property + '" content="' + ov + '" data-dynamic="true"/>');
626						} else {
627							if($('meta[property="' + og_property + '"]').length > 0) $('meta[property="' + og_property + '"]').remove();
628						}
629					});
630				}
631
632				return true;
633			};
634
635			var getPageContentsUrl = function(page) {
636				var contentsParam = param;
637				contentsParam = (page == 'index,template' && contentsParam.indexOf('/org/') == -1) ? contentsParam + '/org/' + page : contentsParam;
638				contentsParam = (b.PUBLISH) ? contentsParam : contentsParam + '/render/true';
639				return '/template/contents/sid/' + b.SID + '/page/' + encodeURIComponent(page) + contentsParam;
640			};
641
642			var isRenderFormSubmitAllowed = function() {
643				if(window.location.pathname.match(/^\/render(\/|$)/) === null) return true;
644				return (b.PREVIEW_FORM_SUBMIT === true || b.PREVIEW_FORM_SUBMIT === 'true');
645			};
646
647			var cachePageContentsResult = function(page, data) {
648				if(!data) return;
649				if(data.conf) b.pageConf[page] = data.conf;
650				if(typeof data.blocks_type != 'undefined') b.pageBlocksType[page] = data.blocks_type;
651				if(typeof data.contents != 'undefined' && page != 'index,template') b.pageContent[page] = data.contents;
652				if(data.initContent !== undefined) b.pageInitContent[page] = JSON.parse(data.initContent);
653			};
654
655			var pageContentsRequests = {};
656			var tabmenuPrefetchTimers = {};
657			var pendingPageClickMove = '';
658			var pendingPageClickMoveTimer = null;
659			var pageContentLoader = null;
660			var pageMoveAOSPending = false;
661			var pageMoveAOSDrawReady = false;
662			var pageMoveAOSScrollTriggered = false;
663			var pageMoveAOSFinishing = false;
664			var pageMoveAOSVersion = 0;
665			var restorePageMoveAOS = function() {
666				$('[data-aos-dummy]').each(function() {
667					$(this).attr('data-aos', $(this).attr('data-aos-dummy')).removeAttr('data-aos-dummy');
668				});
669			};
670			var finishPageMoveAOS = function() {
671				if(!pageMoveAOSPending || !pageMoveAOSDrawReady || !pageMoveAOSScrollTriggered || pageMoveAOSFinishing) return;
672				pageMoveAOSFinishing = true;
673				var version = pageMoveAOSVersion;
674				setTimeout(function() {
675					$('html, body').promise('fx').done(function() {
676						if(version != pageMoveAOSVersion) return;
677						var $pendingAOS = $('.element[data-aos-dummy]').addClass('render-aos');
678						restorePageMoveAOS();
679						$pendingAOS.each(function() { this.offsetHeight; });
680						$pendingAOS.removeClass('render-aos');
681						pageMoveAOSPending = false;
682						pageMoveAOSFinishing = false;
683						if($('.element[data-aos]').length > 0) scheduleBlockAOSRefresh();
684					});
685				}, 0);
686			};
687			var markPageClickMove = function(page) {
688				pendingPageClickMove = normalizeRenderMenuLinkPage(page);
689				if (pendingPageClickMoveTimer) clearTimeout(pendingPageClickMoveTimer);
690				pendingPageClickMoveTimer = setTimeout(function() {
691					pendingPageClickMove = '';
692					pendingPageClickMoveTimer = null;
693				}, 2000);
694			};
695			var consumePageClickMove = function(page) {
696				var matched = pendingPageClickMove
697					&& pendingPageClickMove == normalizeRenderMenuLinkPage(page);
698				pendingPageClickMove = '';
699				if (pendingPageClickMoveTimer) clearTimeout(pendingPageClickMoveTimer);
700				pendingPageClickMoveTimer = null;
701				return !!matched;
702			};
703			var getDirectDsgnBodyUnit = function(element, dsgnBody) {
704				var unit = element;
705				while (unit && unit.parentNode && unit.parentNode !== dsgnBody) unit = unit.parentNode;
706				return unit && unit.parentNode === dsgnBody ? unit : null;
707			};
708			var hidePageContentLoading = function() {
709				if (pageContentLoader && pageContentLoader.parentNode) pageContentLoader.parentNode.removeChild(pageContentLoader);
710				pageContentLoader = null;
711			};
712			var showPageContentLoading = function(preserveTabmenuPage) {
713				hidePageContentLoading();
714				var dsgnBody = document.querySelector('.dsgn-body');
715				if (!dsgnBody) return false;
716
717				var unit = null;
718				if (preserveTabmenuPage) {
719					var preservedRoot = dsgnBody.querySelector('[data-tabmenu-page-preserve]');
720					unit = getDirectDsgnBodyUnit(preservedRoot, dsgnBody);
721				} else {
722					var firstElement = dsgnBody.querySelector('.element[class*="el_"]:not(.el-footer)');
723					unit = getDirectDsgnBodyUnit(firstElement, dsgnBody);
724				}
725
726				var contentHeight = 0;
727				var sibling = preserveTabmenuPage && unit ? unit.nextElementSibling : unit;
728				while (sibling) {
729					if (sibling.classList && (sibling.classList.contains('el-footer') || sibling.classList.contains('fnav'))) break;
730					if (sibling.getBoundingClientRect) contentHeight += sibling.getBoundingClientRect().height;
731					sibling = sibling.nextElementSibling;
732				}
733
734				var loader = document.createElement('div');
735				loader.className = 'render-page-loading';
736				loader.setAttribute('role', 'status');
737				loader.setAttribute('aria-label', 'Loading');
738				loader.style.minHeight = Math.max(180, Math.min(contentHeight, window.innerHeight || 720)) + 'px';
739				loader.innerHTML = '<span class="render-page-loading-spinner" aria-hidden="true"></span>';
740				var insertionPoint = preserveTabmenuPage && unit ? unit.nextSibling : unit;
741				if (!insertionPoint) insertionPoint = dsgnBody.querySelector('.fnav, .el-footer');
742				dsgnBody.insertBefore(loader, insertionPoint || null);
743				pageContentLoader = loader;
744				return true;
745			};
746
747			var loadPageMoveConf = function(page, isForumView) {
748				var deferred = $.Deferred();
749				if(b.pageConf.hasOwnProperty(page)
750					&& (isForumView || b.pageContent.hasOwnProperty(page))
751				) {
752					deferred.resolve(b.pageConf[page]);
753					return deferred.promise();
754				}
755				if(!isForumView && pageContentsRequests[page]) return pageContentsRequests[page];
756
757				if(!isForumView) {
758					pageContentsRequests[page] = deferred.promise();
759					$.ajax({
760						url: getPageContentsUrl(page),
761						data: { siteum: b.SITEUM },
762						dataType: 'json',
763						type: 'GET',
764						async: true,
765						cache: false,
766						success: function(data) {
767							delete pageContentsRequests[page];
768							if(typeof data.url != 'undefined' && data.url) {
769								deferred.resolve(data);
770								return false;
771							}
772							if(typeof data.error != 'undefined' && data.error) {
773								deferred.resolve({});
774								return false;
775							}
776
777							cachePageContentsResult(page, data);
778							deferred.resolve(data.conf || {});
779						},
780						error: function() {
781							delete pageContentsRequests[page];
782							deferred.reject();
783						}
784					});
785				} else {
786					$.ajax({
787						url: '/template/conf',
788						data: { sid : b.SID, page : page, publish : b.PUBLISH, siteum : b.SITEUM },
789						dataType: 'json',
790						type: 'POST',
791						async: true,
792						cache: false,
793						success: function(data) {
794							if(!(typeof data.url != 'undefined' && data.url)) b.pageConf[page] = data;
795							deferred.resolve(data);
796						},
797						error: function() {
798							deferred.reject();
799						}
800					});
801				}
802
803				return deferred.promise();
804			};
805
806			var getTabmenuGroupByPage = function(page) {
807				var normalizedPage = normalizeRenderMenuLinkPage(page);
808				var matchedGroup = null;
809				$.each($.isArray(b.SMENU) ? b.SMENU : [], function(_, menu) {
810					if(!isSiteMenuTabmenuEnabled(menu)) return true;
811					$.each($.isArray(menu.children) ? menu.children : [], function(_, child) {
812						if(!child || child.display === 'off') return true;
813						if(normalizeRenderMenuLinkPage(getRenderMenuPage(child)) != normalizedPage) return true;
814						matchedGroup = menu;
815						return false;
816					});
817					return matchedGroup === null;
818				});
819				return matchedGroup;
820			};
821
822			var getTabmenuPrefetchPages = function(page) {
823				var group = getTabmenuGroupByPage(page);
824				if(!group || group.lock) return [];
825
826				var currentPage = normalizeRenderMenuLinkPage(page);
827				var pages = [];
828				$.each($.isArray(group.children) ? group.children : [], function(_, child) {
829					if(!child || child.display === 'off' || child.lock) return true;
830					var childPage = getRenderMenuPage(child);
831					var normalizedChildPage = normalizeRenderMenuLinkPage(childPage);
832					if(!childPage || normalizedChildPage == currentPage) return true;
833
834					var destination = resolveRenderMenuDestination(b.SMENU || [], child);
835					if(!destination || destination.type != 'page'
836						|| normalizeRenderMenuLinkPage(destination.value) != normalizedChildPage
837					) return true;
838					if($.inArray(childPage, pages) == -1) pages.push(childPage);
839				});
840				return pages;
841			};
842
843			var scheduleTabmenuGroupPrefetch = function(page) {
844				// 원페이지 사이트는 최초 응답에 페이지 블럭이 모두 포함되므로 별도 요청하지 않는다.
845				if(b.ONE || b.VIEW || !page) return;
846				var pages = getTabmenuPrefetchPages(page);
847				$.each(pages, function(index, siblingPage) {
848					if((b.pageContent.hasOwnProperty(siblingPage) && b.pageConf.hasOwnProperty(siblingPage))
849						|| pageContentsRequests[siblingPage]
850						|| tabmenuPrefetchTimers[siblingPage]
851					) return true;
852
853					tabmenuPrefetchTimers[siblingPage] = setTimeout(function() {
854						delete tabmenuPrefetchTimers[siblingPage];
855						loadPageMoveConf(siblingPage, false);
856					}, 100 + (index * 100));
857				});
858			};
859			setTimeout(function() {
860				scheduleTabmenuGroupPrefetch(b.PAGE);
861			}, 500);
862    	$(window).ready(function() {
863    		if(b.VALIDPLAN && $.inArray(b.VALIDTYPE, ['BN','SM']) > -1 && (b.CERT_USE == 'Y' || b.CERT_USE == 'A')) {
864    			if(b.CERT_USE == 'Y') {
865    				if(b.UMEMBER.check_login == true) isUserCertified(history);
866    			} else {
867    				isUserCertified(history);
868    			}
869    		}	
870
871    		if(!b.VALIDPLAN && b.CERT_USE == 'A') {
872    			isUserCertified(history);
873    		}
874
875			var checkIOS = ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) ? true : false;
876			if(checkIOS) $('body').addClass('ios-bg-attachment-scroll');
877    	
878	        (function(window){
879	            var History = window.History;
880	            if ( !History.enabled ) {
881	                return false;
882	            }
883
884	            History.Adapter.bind(window,'statechange',function(){
885					$('.error_404.new_design').remove();
886
887	                var State = History.getState(),
888	                	cUrl = new getLocation(State.url),
889	                	loc = cUrl.pathname,
890	                	uri = (b.PUBLISH) ? loc.replace(/^\//,'').replace(/\/$/,'') : loc.replace(/\/*(render)\/*/,''),
891	                	uri = uri.replace('/view/',','),
892	                	s = uri.split(','),							
893	                	bookmark = '';
894						
895						if (b && b.MODOO === true) {
896								const inSubmenu = Array.isArray(b.SMENU) &&
897									b.SMENU.some(menu =>
898										Array.isArray(menu.children) &&
899										menu.children.some(child =>
900										getRenderMenuPage(child) === decodeURI(uri)
901										)
902									);
903								if (inSubmenu) {
904									//console.log('현재 페이지 서브메뉴 존재');
905									$('.cl-nav-section.sub').show();
906								} else {
907									//console.log('현재 페이지 서브메뉴 없음');
908									$('.cl-nav-section.sub').hide();
909								}
910						}
911
912					if(uri.match(/^(psearch|\_checkout|\_forgot|\_mypayment|\_lang)\//gi) !== null) {
913	                	location.href = '/'+uri;
914	                	return false;
915	                }
916
917					if(uri.match(/^_product\//gi) !== null) {
918						uri = (b.PUBLISH) ? uri : 'render/' + uri;
919						location.href = '/'+uri;
920						return false;
921					}
922					// naverLogCallback(function() {
923					// 	if("naver_log" in b.SETTINGS) {
924					// 		if (!wcs_add) var wcs_add={};
925					// 		wcs_add["wa"] = b.SETTINGS.naver_log;
926					// 		if (!_nasa) var _nasa={};
927					// 		wcs_do(_nasa);
928					// 	}
929					// });
930	                if($('.cl-flat-modal').length > 0) $('.cl-flat-modal .modal').modal('hide');
931
932	                if(uri == b.URL || uri == '') {
933	                	uri = (b.ONE) ? 'index' : b.MENULINK[0];
934	                }
935
936	                (typeof s[1] != 'undefined') ? b.VIEW = s[1] : b.VIEW = '';
937	                b.PAGE = decodeURI(uri);
938	                if(b.PAGE.indexOf('@')>-1) {
939	                	var tmp = b.PAGE.split('@');
940	                	b.PAGE = tmp[0];
941	                	bookmark = tmp[1];
942	                }
943
944	                if((b.PAGE).indexOf(',')>-1) {
945	                	var tmp = b.PAGE.split(',');
946	                	b.VIEW = tmp[1];
947	                }
948					
949			    	getParent(s[0],b.VIEW,b.PAGE);
950					var pageMove = true;
951						
952			    	if(b.VIEW && s[0] != 'forum' && s[0] != 'psearch' && b.COUNT == 0 && !b.PUBLISH) {
953			    		$(this).showModalFlat('INFORMATION','Page not found',true,false,'','ok');
954			    		History.back();
955			    		pageMove = false;
956			    	}
957					if(pageMove) {
958						pageMoveAOSVersion++;
959						pageMoveAOSPending = !!b.PUBLISH;
960						pageMoveAOSDrawReady = false;
961						pageMoveAOSScrollTriggered = false;
962						pageMoveAOSFinishing = false;
963						loadedTabmenuSectionPage = '';
964						var clickedPageMove = consumePageClickMove(b.PAGE);
965						var preserveTabmenuPage = false;
966						if(window.clTabmenu && typeof window.clTabmenu.preparePageChange == 'function') {
967							preserveTabmenuPage = window.clTabmenu.preparePageChange(b.PAGE, {
968								onepage: b.ONE == 1 || b.ONE === true,
969								view: !!b.VIEW
970							});
971						}
972						var cachedTabmenuPage = preserveTabmenuPage
973							&& b.pageContent.hasOwnProperty(b.PAGE)
974							&& b.pageConf.hasOwnProperty(b.PAGE);
975						$('.el-footer').css('visibility', 'hidden');
976						if(!cachedTabmenuPage) {
977							var localPageLoading = (preserveTabmenuPage || clickedPageMove)
978								&& showPageContentLoading(preserveTabmenuPage);
979							if(!localPageLoading) $.processON();
980						}
981						clearDsgnbody();
982			    		pageLoad = true;
983			    		var is_templates = checkTemplateSite(b.SID),
984							menuVer06 = ($('.el-menu .cl-menu-option').length > 0) ? true : false;
985
986			    		var menu_name = (b.VIEW) ? b.PAGE.split(',') : [b.PAGE],
987			    			tmp_url = (is_templates || b.PUBLISH === false) ? '/render' : '',
988							tmp_href = 'a[href="'+tmp_url+'/' + menu_name[0]+'"]',
989			    			pagemenu_link = '#tpl-menu.nav li '+tmp_href;
990
991			    		if(!$(pagemenu_link).parent().hasClass('active')) {
992			              	$('#tpl-menu li').removeClass('active').removeClass('open');
993
994			              	$(pagemenu_link).parent().addClass('active');
995			              	if($(pagemenu_link).closest('.dropdown-menu').length>0) {
996			                  	if($('body').width() > 768) {
997			                  		$(pagemenu_link).closest('.dropdown').addClass('active');
998			                  	} else {
999			                  		$(pagemenu_link).closest('.dropdown').addClass('open');
1000			                  	}
1001			              	} else {
1002			                	if($('.el-menu > header').hasClass('navbar-fheader')) $('#mobile-nav li.menu-has-children ul.dropdown-menu').hide();
1003				                else {
1004				                  if($('body').width() <= 768) $('#tpl-menu li.dropdown ul.dropdown-menu').hide();
1005				                }
1006			              	}
1007			            }
1008
1009						if(menuVer06) {
1010							$('.el-menu .cl-moption-row').removeClass('active');
1011							$('.el-menu .cl-moption-row '+tmp_href).closest('.cl-moption-row').addClass('active');
1012							if($('.el-menu .cl-moption-row '+tmp_href).closest('.cl-moption-row[data-parent]').length > 0) $('.el-menu .cl-moption-row '+tmp_href).closest('.cl-moption-col').find('.cl-moption-row:not([data-parent])').addClass('active');
1013
1014							$('#mobile-nav li.menu-has-children').removeClass('open');
1015							$('#mobile-nav li.menu-has-children ul.dropdown-menu').hide();
1016							$('#mobile-nav '+tmp_href).closest('li.menu-has-children').addClass('open');
1017							$('#mobile-nav '+tmp_href).closest(' ul.dropdown-menu').show();
1018						}
1019
1020
1021			            if($('.shopping-more-wrap').length > 0) $('.shopping-more-wrap').remove();
1022			            // console.log('pageMove', $.cookie('prev-forum-view'));
1023			            if(s[0] != 'forum' && $.cookie('prev-forum-view') === undefined) {
1024			            	// console.log('forum cookie');
1025			            	$.each(document.cookie.split(';'), function(index, cookie) {
1026								var name = cookie.split('=')[0].trim();
1027								if (name.indexOf('forum_') === 0) {
1028					                $.removeCookie(name, {path:'/'})
1029									// document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
1030								}
1031							});
1032				            }
1033				            $.removeCookie('prev-forum-view', {path:'/'});
1034							var continuePageDraw = function() {
1035									$('body').find('.galProjectCss').remove();
1036									if($('.popup').length) $('.popup').remove(); //clear Popup;
1037									if(b.SETTINGS.noError404 === true && !(b.MENULIST.indexOf(b.PAGE) > -1) && !b.ONE && !b.VIEW) { // page move
1038									window.location.href = '/';
1039									return false;
1040								}
1041								showPageCallback(showPage, function() {
1042									syncRenderUserLinksByMenuUid(b.SMENU, b.ONE, b.VIEW);
1043									var pgmove_vMode = (typeof $('.mobilepc_ch').attr('data-desktop-option')!='undefined') ? $('.mobilepc_ch').attr('data-desktop-option') : '';
1044									pgmove_vMode = $.mpcWeb.mpcGetVpmode(pgmove_vMode,b.SETTINGS);
1045									if(b.VALIDPLAN && b.VALIDTYPE != 'PK') {
1046										if(typeof b.SETTINGS.viewportMode != 'undefined' && b.SETTINGS.vpMode_onoff===true) $.mpcWeb.mpcWebhtml(pgmove_vMode,b.pageContent[b.PAGE],b.SETTINGS.zoom,'pagemove');
1047									}
1048
1049									setTimeout(function() {
1050										if(b.VALIDPLAN && b.VALIDTYPE != 'PK') {
1051											if(b.ONE && !b.VIEW || (b.PAGE == b.MENULINK[0]) && !b.VIEW) setSitePopup();
1052											$.siteBanner.init(true,true);
1053										}
1054
1055										if(b.VALIDPLAN && (b.VALIDTYPE == 'BN' || b.VALIDTYPE == 'SM')) {
1056											if(typeof b.SETTINGS.fnav != 'undefined' && !$.isEmptyObject(b.SETTINGS.fnav) && (typeof b.SETTINGS.qm_onoff == 'undefined')) {
1057												$.fnav.draw(b.SETTINGS.fnav);
1058											}
1059											if(typeof b.SETTINGS.qm_onoff != 'undefined' && b.SETTINGS.qm_onoff==true) {
1060												var quick_type = ($('body').width() > 768) ? 'pc' : 'mobile';
1061												if(!(b.PARENT.page != null && (quick_type=='mobile'))) {
1062													$.quickmenu.init(b.SID, b.PUBLISH,quick_type);
1063													mobileWebQuickmenuPosition(b,quick_type);
1064												} else {
1065													$(`.quick-menu-${b.SID}`).remove();
1066												}
1067											}
1068										}
1069										if(b.VALIDPLAN && b.VALIDTYPE != 'PK') {
1070											if(typeof b.SETTINGS.viewportMode != 'undefined' && b.SETTINGS.vpMode_onoff===true) {
1071												mobileWebfnavCheck(pgmove_vMode);
1072											}
1073										}
1074										
1075										// 원페이지, 갤러리 상세페이지에서 메뉴 클릭 시 페이지 이동 후 해당 메뉴로 이동하지 않고 상단 고정 Issue Fix (https://flow.team/l/1x7rX)
1076										if(typeof b.SID != 'undefined' && b.SID && b.SID == 'ronixinc') {
1077											if(location.hash) {
1078												var hash = decodeURIComponent(location.hash.substring(1));  
1079												console.log('해시 감지:', hash);
1080												
1081												setTimeout(function() {
1082													var $block = getRenderOnepagePageBlock(hash);
1083													
1084													if($block.length > 0) {
1085														var blockTop = $block.offset().top;
1086														var currentScroll = $(window).scrollTop();
1087														var threshold = 100;
1088														
1089														if(Math.abs(blockTop - currentScroll) > threshold) {
1090															console.log('스크롤 필요:', {current: currentScroll, target: blockTop});
1091															moveLinkPage(hash);
1092														} else {
1093															console.log('이미 근처에 있음, 스크롤 생략');
1094														}
1095													} else {
1096														console.error('블록 없음:', hash);
1097													}
1098												}, 500);
1099											}
1100										}
1101
1102									}, 500);
1103								});
1104
1105								if(typeof $.cookie('gallery-return-page') != 'undefined' && b.VIEW == '') {
1106									setTimeout(function() {
1107										restoreGalleryReturnTarget();
1108									}, 100);
1109								} else if(typeof $.cookie('gallery-item') != 'undefined' && b.VIEW == '') {
1110									setTimeout(function() {
1111										moveGallery($.cookie('gallery-item'));
1112									},500);
1113								} else if(typeof $.cookie('gallery') != 'undefined' && b.VIEW == '') {
1114									setTimeout(function() {
1115										moveGallery($.cookie('gallery'));
1116									},500);
1117								} else if(typeof $.cookie('forum-item') != 'undefined' && b.VIEW == '') {
1118									// console.log('fm_view', $.cookie('forum_content_view'));
1119									setTimeout(function() {
1120										if(typeof $.cookie('forum_content_view') != 'undefined'){
1121											var fm_view = $.cookie('forum_content_view');
1122											var fv = (fm_view !== undefined && fm_view)? fm_view.split('&'):array();
1123											var pid = (fv)? fv[0]:'';
1124											var row_id = (fv)? fv[1]:'';
1125
1126											scrollToBlock('.element[data-id="' + $.cookie('forum-item') + '"] .tpl-forum-list-title[data-id="'+row_id+'"]', 1000);
1127											$.removeCookie('forum-item', { path: '/' });
1128											
1129											$('.element[data-id="' + pid + '"] .tpl-forum-list-title[data-id="'+row_id+'"]').click();
1130											// $.removeCookie('forum_content_view', { path: '/', expires: 12 * 60 * 60 * 1000 });
1131										} else {
1132											scrollToBlock('.element[data-id="' + $.cookie('forum-item') + '"]', 1000);
1133											$.removeCookie('forum-item', { path: '/' });
1134										}
1135									}, 500);
1136								} else {
1137									var url = window.location;
1138									var pageMoveAOSScrollVersion = pageMoveAOSVersion;
1139									setTimeout(function() {
1140										moveScroll(0,url.href);
1141										if(pageMoveAOSPending && pageMoveAOSScrollVersion == pageMoveAOSVersion) {
1142											pageMoveAOSScrollTriggered = true;
1143											finishPageMoveAOS();
1144										}
1145									},300);
1146								}
1147								if(pageMoveAOSPending) {
1148									var fallbackMoveAOSVersion = pageMoveAOSVersion;
1149									setTimeout(function() {
1150										if(fallbackMoveAOSVersion != pageMoveAOSVersion || !pageMoveAOSPending) return;
1151										pageMoveAOSScrollTriggered = true;
1152										finishPageMoveAOS();
1153									}, 1200);
1154								}
1155								if(typeof b.SETTINGS.google != 'undefined' && b.SETTINGS.google.length > 0) {
1156									var https_check = (location.protocol=='https:') ? 'https:' : 'http:',
1157										host_url = b.URL +  b.PAGE;
1158
1159									host_url = (b.PARENT && b.PARENT.mode=='project') ? (host_url.replace(/,/g,"/view/")) : host_url;  
1160
1161									if(b.SETTINGS.google.indexOf('UA-') > -1) ga('send', 'pageview', location.pathname);
1162									else if(b.SETTINGS.google.indexOf('G-') > -1) {
1163										gtag('config', b.SETTINGS.google, {
1164											page_title: b.TITLE,
1165											page_location: https_check + '//'+ b.HOST + host_url,
1166											page_path: host_url
1167										});
1168									}
1169									//else gtag('config', b.SETTINGS.google , {page_path : location.pathname});
1170									//console.log(https_check + '//'+ b.HOST + host_url);
1171									// console.log('google analytics send, pageview');
1172								}
1173								if(typeof b.SETTINGS.npay_setting != 'undefined' && b.SETTINGS.npay_setting.onoff == true && b.SETTINGS.npay_setting.naver_log.length > 0) {
1174									wcs_do();
1175									// console.log('naverpay log');
1176								} else {
1177									if(typeof b.SETTINGS.naver_log != 'undefined' && b.SETTINGS.naver_log.length > 0) {
1178										wcs.inflow();
1179										wcs_do(_nasa);
1180										// console.log('naver analytics send, pageview');
1181									}
1182								}
1183								if(typeof b.SETTINGS.gtag_event != 'undefined' && typeof b.SETTINGS.gtag_event.page != 'undefined' && b.SETTINGS.gtag_event.page.length > 0) {
1184									if(typeof b.SETTINGS.gtag_event.type != 'undefined' && b.SETTINGS.gtag_event.type == 'event' && b.SETTINGS.gtag_event.page == b.PAGE) {
1185										// console.log(b.SETTINGS.gtag_event);
1186										var v0 = b.SETTINGS.gtag_event.val[0],
1187											v1 = b.SETTINGS.gtag_event.val[1],
1188											v2 = b.SETTINGS.gtag_event.val[2];
1189
1190										gtag(b.SETTINGS.gtag_event.type,v0,{v1:v2});
1191										// gtag(b.SETTINGS.gtag_event.type, b.SETTINGS.gtag_event.val[0], { b.SETTINGS.gtag_event.val[1] : b.SETTINGS.gtag_event.val[2] });
1192									}
1193								
1194								}
1195
1196								// menu ver3 : fheader
1197								setTimeout(function() {
1198									if($('header.navbar').hasClass('navbar-fheader')) $.fheader.position();
1199								},400);
1200
1201
1202								// favicon refresh
1203								var favicon = b.RESOURCE + '/' + b.SID + '/' + b.SID + '-favicon.ico?_' + new Date().getTime();
1204								changeFavicon(favicon);
1205
1206									if(typeof pageMoveCallback == 'function') pageMoveCallback();
1207									formTranslate(LANG);
1208
1209								};
1210
1211							loadPageMoveConf(b.PAGE, (s[0] == 'forum' && b.VIEW)).done(function(data) {
1212								if(applyPageConf(data) === false) {
1213									hidePageContentLoading();
1214									if(window.clTabmenu && typeof window.clTabmenu.finishPageChange == 'function') window.clTabmenu.finishPageChange();
1215									return false;
1216								}
1217								if(b.pageInitContent.hasOwnProperty(b.PAGE)) property.INITPAGE = b.pageInitContent[b.PAGE];
1218								scheduleTabmenuGroupPrefetch(b.PAGE);
1219								continuePageDraw();
1220							}).fail(function() {
1221								hidePageContentLoading();
1222								if(window.clTabmenu && typeof window.clTabmenu.finishPageChange == 'function') window.clTabmenu.finishPageChange();
1223								$.processOFF();
1224							});
1225							}
1226		            });
1227
1228				History.Adapter.bind(window, 'popstate', function() { // history.js suggests statechange but it has a bug with urls with hashes not firing statechange
1229	                var State = History.getState(),
1230	                	cUrl = new getLocation(State.url),
1231	                	bUrl = new getLocation(window.location.href);
1232
1233	                if(b.ONE) {
1234	                	if(cUrl.href!=window.location.href) {
1235	                		if(b.PAGE!='index') {
1236	                			var link = (!b.PUBLISH) ? '/render/index' : bUrl.pathname;
1237								var url = new getLocation(link);
1238					        	golink(_this,url);
1239								history.pushState('', '', link + bUrl.hash);
1240	                		} else {
1241	                			// if(bUrl.hash) {
1242	                			// 	var go = (bUrl.hash).replace('#','');
1243	                			// 	moveLinkPage(go);
1244	                			// }
1245	                		}
1246	                	}
1247	                }
1248				});
1249
1250	        })(window);
1251
1252		    $('.dsgn-body').addClass('mode-render');
1253	    	//$.modalON();
1254
1255			if(typeof b.SETTINGS == 'undefined') return;
1256			// if(typeof b.SETTINGS.rightClick == 'undefined' || b.SETTINGS.rightClick === false) return;
1257			if(!b.VALIDTYPE || b.VALIDTYPE == 'PK' || typeof b.SETTINGS.rightClick == 'undefined' || b.SETTINGS.rightClick === false) {
1258				b.SETTINGS.rightClick = false;
1259				return;
1260			}
1261		    $('body').on('contextmenu', function(event){ return false; });
1262			$('body').on('selectstart', '.element, .forum-view, .comment-list', function(event){ return false; });
1263	    	$('body').on('dragstart', '.element, .forum-view, .comment-list',  function(event){ return false; });
1264
1265	    	// MutationObserver의 콜백 함수 정의
1266			const observerCallback = function(mutationsList) {
1267			  	for (const mutation of mutationsList) {
1268			    	if (mutation.type === 'childList') {
1269			      		// DOM 변화가 감지되면 AOS.refresh 호출
1270			      		AOS.refresh();
1271			    	}
1272			  	}
1273			};
1274			// MutationObserver 인스턴스 생성
1275			const observer = new MutationObserver(observerCallback);
1276			// 관찰할 옵션 정의
1277			const config = { 
1278			  	childList: true, 
1279			  	subtree: true
1280			};
1281			// 감지할 요소 선택
1282			const targetNode = document.querySelector('.dsgn-body');
1283			if (targetNode) {
1284			  	observer.observe(targetNode, config);
1285			}
1286	    });
1287
1288		Pace.on('done', function() {
1289			/*shopping more create*/
1290			if($('.shopping-wrap').length && $('.shopping-wrap').height() >= 800 && $('.shopping-more').length == 0) {
1291				var more_txt = (LANG == 'ko') ? '상품정보 더보기' : 'MORE';
1292				var review_chk = ($('.cl-s-product-review').length > 0) ? true : false,
1293					qna_chk = ($('.cl-s-product-qna').length > 0) ? true : false;
1294				var colorSet = shopping_more_color,
1295					sm_font = (!colorSet) ? '' : colorSet.color,
1296					sm_bgColor = (!colorSet) ? '' : colorSet.background_color,
1297					sm_border = (!colorSet) ? '' : colorSet.border_color;
1298				$('.shopping-wrap').css('max-height','800px')
1299								   .css('overflow','hidden')
1300								   .after('<div class="shopping-more-wrap"><div class="shopping-more">'+more_txt+'</div></div>');
1301				$('.shopping-wrap').removeClass('open');
1302				if(sm_font) $('.shopping-more').css('color',sm_font);
1303				if(sm_bgColor) $('.shopping-more').css('background-color',sm_bgColor);
1304				if(sm_border) $('.shopping-more').css('border-color',sm_border);
1305				if(!review_chk && !qna_chk) $('.shopping-more-wrap').css('padding-bottom','100px');
1306			}
1307			
1308			var header_h = $('header').outerHeight();
1309			var menu_logo = $('.menu-logo-top');
1310			var menu_logo_h = (menu_logo.length > 0) ? menu_logo.outerHeight() : 0;
1311			$('.dsgn-body')[0].style.setProperty('--menu-logo-height', menu_logo_h+'px');
1312			$('.dsgn-body')[0].style.setProperty('--header-height', header_h+'px');
1313
1314			setTimeout(function() { 
1315				$('body').removeClass('pace-disable'); 
1316			},500);
1317			if(typeof $.cookie('gallery-return-page') != 'undefined' && b.VIEW == '') {
1318				restoreGalleryReturnTarget();
1319			} else if(typeof $.cookie('gallery-item') != 'undefined' && b.VIEW == '') {
1320				moveGallery($.cookie('gallery-item'));
1321			}
1322			$.modalOFF();
1323			if(!property.ONE) {
1324				moveScroll(0);
1325			} else {
1326				// onepage index movescroll
1327				if(b.PAGE=='index' && b.MODE == 'publish' && !menuClickMove) {
1328					var bUrl = new getLocation(window.location.href),
1329						moveId = (bUrl.pathname).replace('/','');
1330					if(moveId != 'index') moveLinkPage(moveId);
1331				}
1332			}
1333
1334			$.each($('.element'), function(k,v) {
1335				var checkNotSupported = false,
1336					not_supported_mode = '',
1337					check_video_version = true,
1338					bg_vid_gfyposter = (typeof $(this).find('.bgvid source.display').attr('src') != 'undefined') ? $(this).find('.bgvid source.display').attr('src') : '',
1339					vid_regex = /gfycat\.com/gi;
1340			
1341				if($(this).attr('data-type') == 'video' && typeof $(this).attr('data-playtype') == 'undefined' && (vid_regex.test(bg_vid_gfyposter))) {
1342					check_video_version = false;
1343					checkNotSupported = true;
1344					not_supported_mode = $(this).attr('data-type'),
1345					el_seq = $(this).attr('data-id');
1346				
1347					if(checkNotSupported) {
1348						var upgrade_check = (!check_video_version) ? false : true;
1349						$.notSupported.set(property.SID, el_seq, not_supported_mode, upgrade_check);
1350					}
1351				}
1352			});
1353
1354		});
1355
1356		// naverLogCallback(function() {
1357		// 	if("naver_log" in b.SETTINGS) {
1358		// 		if (!wcs_add) var wcs_add={};
1359		// 		wcs_add["wa"] = b.SETTINGS.naver_log;
1360		// 		if (!_nasa) var _nasa={};
1361		// 		wcs_do(_nasa);
1362		// 	}
1363		// });
1364		
1365		if(typeof pageMoveCallback == 'function') pageMoveCallback();
1366		formTranslate(LANG);
1367
1368	    $('.dsgn-body').addClass('mode-render');
1369
1370		var is_templates = (typeof property.SID != 'undefined') ? checkTemplateSite(property.SID) : false;
1371
1372		//갤러리 블럭에서 카테고리가 비었습니다 문구가 영문 템플릿에서 한글로 나오는 이슈로 아래 코드 추가, 문제 시 삭제 or 위치변경
1373		if(is_templates && property.SID.indexOf('_en') > -1) LANG = 'en';
1374
1375	    if(property.VALIDPLAN || is_templates) {
1376			$('body,.dsgn-body').removeClass('with-creatorlink');
1377	    } else {
1378	    	$('body,.dsgn-body').addClass('with-creatorlink');
1379	    }
1380	    // $('button.navbar-toggle').addClass('hide');
1381    	// (b.WRAP) ? $('.dsgn-body').addClass('tiny') : $('.dsgn-body').removeClass('tiny');
1382
1383		var $tag = $('header');
1384
1385		// 중복된 .header.el-menu 래퍼가 이미 존재하는지 확인
1386		var $parent = $tag.parent();
1387		if ($parent.is('.header.el-menu')) {
1388			// 이미 header를 감싸고 있는데 또 .header.el-menu가 감싸고 있다면, 외부 .header.el-menu 제거
1389			if ($parent.parent().is('.header.el-menu')) {
1390				$parent.unwrap();
1391			}
1392		} else {
1393			// 감싸는 div가 없을 경우만 새로 감쌈
1394			var _ready = (!$.isEmptyObject(property.SETTINGS.modoo || {})) ? '_ready' : '';
1395			var _elmenu = $('<div>', {
1396				'class': 'header el-menu ' + _ready,
1397				'data-el': 'el-menu',
1398				'data-id': 'menu',
1399				'data-name': 'menu'
1400			});
1401			$tag.wrap(_elmenu);
1402		}
1403
1404		if($tag.is('.cl-nav')) $('.dsgn-body').before($('.header.el-menu'));
1405
1406		changeBrokenImages($tag);
1407
1408		$tag.removeClass('tpl-menu');
1409		if(b.ONE){
1410			if(b.VIEW) $tag.find('#site-home').attr('href',URI).removeClass('mini-home');
1411			else $tag.find('#site-home').attr('href','javascript:;').addClass('mini-home');
1412		} else $tag.find('#site-home').attr('href',URI).removeClass('mini-home');
1413
1414
1415		var isHeaderOldVer = !$.clnav.check();
1416		var isSidebar = $tag.hasClass('sidebar');
1417		var isSiteLock = b.SITELOCK;
1418		if(isHeaderOldVer) {
1419			if(isSidebar) {
1420				$('.dsgn-body').addClass('sidebar');
1421				$('.header.el-menu').addClass('sidebar');		
1422			} else if(b.HEADER) {
1423				$('header.navbar').addClass('transparent');
1424			}
1425
1426			header_fixed = $('header.navbar').height();
1427			if($('header.navbar').css('background-color')=='rgba(0, 0, 0, 0)'
1428				&& $('header.navbar').css('background-image')=='none'
1429			) {
1430				$('header.navbar').css('background-color',$('dsgn-body').css('background-color'));
1431			}
1432		}
1433
1434
1435		if(isSidebar) {
1436			if($tag.hasClass('hide') && $('.dsgn-body').hasClass('sidebar'))
1437				$('.dsgn-body').removeClass('sidebar');
1438
1439			// console.log(isSiteLock);
1440			if(isSiteLock == 'true') {
1441				$('.dsgn-body').addClass('site_lock');
1442			} else {
1443				$('.dsgn-body').removeClass('site_lock');
1444			}
1445		}
1446		
1447		// footer
1448		$('.footer-' + b.SID).addClass('el-footer').addClass('element').attr('data-type','footer');
1449
1450	    $(window).on('scroll',function() {
1451	    	if($('.dsgn-body').hasClass('mobile-nav-active')) return false;
1452
1453			if($(this).scrollTop() > 200) {
1454				$('#goto-top').addClass('show');
1455			} else {
1456				$('#goto-top').removeClass('show');
1457			}
1458
1459	        if($('.dsgn-body').hasClass('sidebar')==false) {
1460	            fixedMenu();
1461	        }
1462
1463	        if($(this).scrollTop() == 0 && $('header').hasClass('navbar-fheader')) {
1464				setTimeout(function() { $.fheader.position(); }, 200);
1465			}
1466	        scrollspy();
1467			
1468	        //parallax();
1469
1470	    });
1471
1472		$(window).on('orientationchange',function(){
1473			if($('.blueimp-gallery-display').length) {
1474				var $slide = $('.blueimp-gallery .slides .slide'),
1475					play = $('.blueimp-gallery-playing').length,
1476					idx = 0;
1477				$.each($slide, function(i,v) {
1478		        	var trans = $(this).attr('style');
1479		        	if(trans.indexOf('translate(0px, 0px)') > 0) {
1480		        		idx = $(this).attr('data-index');
1481		        	}
1482				});
1483
1484				var gallery = $('.blueimp-gallery-display').attr('id');
1485
1486				$('#' + gallery + ' .close').click();
1487				$.processON();
1488				setTimeout(function() { 
1489					$.processOFF() ; 
1490					$('.gallery-item[data-index="' + idx + '"] a[data-gallery="#' + gallery + '"]').click(); 
1491					$('.layout-grid').eq(idx).find('a[data-gallery="#' + gallery + '"]').click(); 
1492					if(play) $('#' + gallery + ' .play-pause').click();
1493				}, 1000);
1494			}
1495		});
1496
1497		var currentWindowWidth = $(window).width();
1498		$(window).resize(function () {
1499			$('.config-image-view').hide();
1500			if($('body').width() <= 768 && $('.dsgn-body').hasClass('sidebar')) {
1501				if($('header.navbar').hasClass('sidebar')) {
1502					cssSidebar('off');
1503				}
1504				//$('.dsgn-body').removeClass('sidebar').addClass('removed-sidebar');
1505			} else if ($('body').width() > 768 /*&& $('.dsgn-body').hasClass('removed-sidebar')*/) {
1506				if($('header.navbar').hasClass('sidebar')) {
1507					cssSidebar('on');
1508				}
1509				//$('.dsgn-body').removeClass('removed-sidebar').addClass('sidebar');
1510				var top = ($('.creatorlink-header').length == 1) ? '55px' : '0px';
1511				$('.el_0').css('margin-top',top);
1512				if($('.header-empty').length > 0) $('.header-empty').remove();
1513			}
1514
1515            if( $('.header-empty').length > 0 && $('.header-empty').height() != $('.el-menu').height() ) {
1516            	$('.header-empty').css('height',$('.el-menu').height()+'px');
1517            }
1518
1519			// menu ver3 : fheader
1520			if($('header.navbar').hasClass('navbar-fheader')) $.fheader.position();
1521			
1522	        if($('body').width() <= 768) {
1523	            if($('#tpl-menu li.active.dropdown').length > 0) $('#tpl-menu li.active.dropdown').removeClass('active');
1524	        } else {
1525	            if($('#tpl-menu li.active').closest('ul').hasClass('dropdown-menu')) $('#tpl-menu li.active').closest('li.dropdown').addClass('active');
1526	            $('#tpl-menu ul.dropdown-menu').removeAttr('style');
1527	        }
1528
1529			if($('.element[data-type="video"] .lyoption[data-lyh]').length > 0) setLayoutHeight();
1530
1531	        var vpmode_opt = $('.mobilepc_ch').attr('data-desktop-option'),
1532     	 	   	vpmode = vpmode_opt ? vpmode_opt : b.SETTINGS.viewportMode,
1533         	    vpModeOnoff = (property.SETTINGS.vpMode_onoff === true) ? true : false,
1534         	    checkFnav = ($('.fnav').length > 0 && vpmode=='mobile_web') ? true : false,
1535         	    WebType = $.mpcWeb.mpcCheckWebType();
1536
1537	        if($('.fnav').length > 0) {
1538	            if($('body').width() <= 480) {
1539	            	if($('#cl-music-player-icon').length > 0) $('#goto-top,#cl-music-player-icon').addClass('movedOne');
1540	            } 
1541	        }
1542
1543	        if(vpModeOnoff && WebType == 'MOBILE') {
1544				$.mpcWeb.mpcMusicandGoTop(checkFnav,vpmode);
1545				var device_type = ($('body').width() > 768) ? 'pc' : 'mobile';
1546				if(typeof $.quickmenu['quickmenu'] != 'undefined' && $.quickmenu['quickmenu']['img_type'][device_type.toLowerCase()]!='bottom_default') {
1547					var mpc_height = $('.mobilepc_ch').innerHeight(),
1548						add_height = ($('#cl-music-player-icon').length > 0) ? 45 : 30;
1549					$(`.quick-menu-${b.sid}.quickmenu`).css('bottom', mpc_height + add_height);	
1550				}
1551			}
1552
1553	        fixedMenu();
1554	        scrollspy();
1555			$('.element[data-type="video"], .element[data-type="others"]').each(function() {
1556				resizeVideoIframe($(this));
1557			});
1558
1559			//premium gallery setFixedscroll
1560			if($('.element[data-feature*=fixedscroll]').length > 0) gjs01SetFixedscroll($('.element[data-feature*=fixedscroll]').eq(0));
1561	        
1562	        if($('.fr-view').length) {
1563	            setForumWrap();
1564	        }
1565
1566	        if($('.blueimp-gallery-display').length) {
1567	            if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement) {
1568	                return; 
1569	            }
1570
1571		        var $slide = $('.blueimp-gallery .slides .slide'),
1572		            play = $('.blueimp-gallery-playing').length,
1573		            idx = 0;
1574		        $.each($slide, function(i,v) {
1575		            var trans = $(this).attr('style');
1576		            if(trans.indexOf('translate(0px, 0px)') > 0) {
1577		                idx = $(this).attr('data-index');
1578		            }
1579		        });
1580
1581		        var gallery = $('.blueimp-gallery-display').attr('id');
1582
1583		        $('#' + gallery + ' .close').click();
1584		        $.processON();
1585		        setTimeout(function() { 
1586		            $.processOFF() ; 
1587		            $('.gallery-item[data-index="' + idx + '"] a[data-gallery="#' + gallery + '"]').click(); 
1588		            $('.layout-grid').eq(idx).find('a[data-gallery="#' + gallery + '"]').click(); 
1589		            if(play) $('#' + gallery + ' .play-pause').click();
1590		        }, 1000);
1591		    }
1592	        sitePopupResize();
1593
1594	        if($('.element[data-type="contact"][data-type2="franchise map"]').length > 0) {
1595	        	let newWidth = $(window).width();
1596	        	if (currentWindowWidth !== newWidth) {
1597			        $('.element[data-type="contact"][data-type2="franchise map"]').each(function(idx, v){
1598		        		var el = $(v);
1599		        		fmapMobilePaging(el);
1600		        	});
1601			    }
1602			    
1603			    currentWindowWidth = newWidth;
1604	        }
1605
1606			// if(typeof b.SETTINGS.qm_onoff != 'undefined' && b.SETTINGS.qm_onoff==true) {
1607			// 	var device_type = ($('body').width() > 768) ? 'pc' : 'mobile';
1608			// 	alert('resize')
1609			// 	$.quickmenu.setHTML($.quickmenu['quickmenu'], device_type);
1610			// }
1611
1612			var header_h = $('header').outerHeight();
1613			$('.dsgn-body')[0].style.setProperty('--header-height', header_h+'px');
1614
1615	        var checkFixTypeMenu = (typeof $('header.navbar-fheader').attr('data-fixtype') != 'undefined' && $('header.navbar-fheader').attr('data-fixtype')) ? true : false;
1616			if(b.VALIDPLAN && checkFixTypeMenu) {
1617	            if(window.innerWidth < 769) {
1618		            $('header.navbar[data-fixtype]').find('.navbar-brand').css('line-height','');
1619		            return false;
1620		        }
1621				setTimeout(function(){
1622					setFixedMenuCss(false);
1623				},80);
1624	        }
1625			if($('.element[data-aos]').length > 0) scheduleBlockAOSRefresh();
1626	    });
1627	    this.liveUpdate(b.SMENU);
1628
1629	    var checkToggleShow = (!b.MENUCHECK.main && window.innerWidth > 768) ? false : true,
1630			loc_pathname = window.location.pathname,
1631	    	is_render = (loc_pathname.match(/^\/render/g)) ? true : false,
1632	    	is_templates = (typeof b.SID != 'undefined') ? checkTemplateSite(b.SID) : false;
1633	    // if(is_render && !is_templates) {
1634		// 	if(window.parent && window.parent != this && $('#previewmain', window.parent.document).length > 0) {
1635		// 		if($('#previewmain', window.parent.document).find('.preview-hand .active').is('#desktop, #tablet') && !b.MENUCHECK.main) checkToggleShow = false;
1636		// 	}
1637	    // }
1638	    // if(checkToggleShow) $('button.navbar-toggle').css('visibility','visible');
1639
1640		//cross-origin 오류수정
1641		if (is_render && !is_templates) {
1642			try {
1643				if (window.parent && window.parent !== window && $('#previewmain', window.parent.document).length > 0) {
1644					if ($('#previewmain', window.parent.document).find('.preview-hand .active').is('#desktop, #tablet') && !b.MENUCHECK.main) {
1645						checkToggleShow = false;
1646					}
1647				}
1648			} catch (e) {
1649				console.warn('parent document 접근 불가(cross-origin)', e);
1650			}
1651		}
1652
1653		if (checkToggleShow) {
1654			$('button.navbar-toggle').css('visibility', 'visible');
1655		}
1656
1657
1658		if(b.PAGE == 'psearch') $.psearch.view();
1659
1660		$('[data-imglink="true"][attr-link]').live('click',function(){
1661	    	if($(this).is('[attr-link=""]')) return false;
1662
1663		    var imgtarget = $(this).attr('data-target'),
1664		        imgshlink = $(this).attr('data-shlink'),
1665		        imgblank = $(this).attr('data-blank');
1666
1667		    if(imgblank == '_blank') {
1668		        var openNewWindow = window.open('about:blank');
1669		            openNewWindow.location.href=imgshlink; 
1670		    } else {
1671		        location.href=imgshlink;
1672		    }
1673		});
1674
1675		$('.menu-inner').on('scroll', function() {
1676	        $(this).next('.fh-line').show();
1677	        if($(this).scrollTop()==0) $(this).next('.fh-line').hide();
1678	    });
1679
1680	    $("#mobile-nav #tpl-menu").on('scroll', function() {
1681	       	$(this).next('.fh-line').show();
1682	       	if($(this).scrollTop()==0) $(this).next('.fh-line').hide();
1683	    });
1684
1685		$('.sitePopupTodayHide, .sitePopupClose').live({
1686			click: function() {
1687				if($(this).hasClass('sitePopupTodayHide')) $(this).find('input').click();
1688				var selectedPopup = $(this).closest('.modal-popup').attr('id');
1689				$('#' + selectedPopup).find('.popup-close').click();
1690			}
1691		});
1692
1693		$('.popup-close').live({
1694		    click: function() {
1695		        var selectedPopup = $(this).closest('.modal-popup').attr('id'),
1696		            idx = $(this).closest('.modal-popup').attr('data-idx'),
1697		            ptime = $(this).closest('.modal-popup').attr('data-time'),
1698		            isTodayHide = $(this).closest('.modal-popup').find('.sitePopupTodayHide input').prop('checked'),
1699		            date = new Date();
1700		            
1701		        var ptime_val = {
1702					'always'    : 0,
1703					'onlyone'   : 365 * 24 * 60 * 60 * 1000,
1704					'week'      : 7 * 24 * 60 * 60 * 1000, 
1705					'day'       : 24 * 60 * 60 * 1000, 
1706					'12hour'    : 12 * 60 * 60 * 1000, 
1707					'6hour'     : 6 * 60 * 60 * 1000, 
1708					'2hour'     : 2 * 60 * 60 * 1000, 
1709					'1hour'     : 60 * 60 * 1000, 
1710					'30min'     : 30 * 60 * 1000, 
1711					'10min'     : 10 * 60 * 1000
1712		        };
1713
1714		        if(isTodayHide) {
1715		        	date.setTime(date.getTime() + ptime_val['day']);
1716		        } else { 
1717		        	date.setTime(date.getTime() + ptime_val[ptime]);
1718		        }
1719		        $('#' + selectedPopup).fadeOut();
1720		        if(isTodayHide || (typeof ptime !='undefined' && ptime != 'always' && ptime != '')) { $.cookie(selectedPopup, true, { path: '/', expires: date}); }
1721		        else { $.removeCookie(selectedPopup, { path: '/' }); }
1722		    }
1723		});
1724
1725		var decodeMoveScrollUrl = function(value) {
1726            if(typeof value == 'undefined' || !value) return '';
1727
1728            var url = String(value);
1729
1730            try {
1731                var decoded = decodeURIComponent(url);
1732                if(decoded !== url) return decoded;
1733            } catch(e) {}
1734
1735            try {
1736                var escaped = escape(url);
1737                if(escaped.indexOf('%u') === -1) return decodeURIComponent(escaped);
1738            } catch(e) {}
1739
1740            return url;
1741        };
1742
1743		var loadedTabmenuSectionPage = '';
1744		var applyOnepageDirectMenuDestination = function(interval) {
1745			if(!b.ONE || !location.hash) return false;
1746
1747			var hash = '';
1748			try {
1749				hash = decodeURIComponent(location.hash.replace(/^#/, ''));
1750			} catch(e) {
1751				hash = location.hash.replace(/^#/, '');
1752			}
1753			var sourcePage = String(hash || '').split('@')[0];
1754			var source = getRenderMenuPageMap(b.SMENU || [])[normalizeRenderMenuLinkPage(sourcePage)];
1755			if(!source || !usesRenderResolvedMenuPolicy()) return false;
1756
1757			var destination = resolveRenderMenuDestination(b.SMENU || [], source);
1758			if(!destination || destination.type == 'invalid' || destination.type == 'cycle') return false;
1759			if(destination.type == 'page' && normalizeRenderMenuLinkPage(destination.value) == normalizeRenderMenuLinkPage(sourcePage)) return false;
1760
1761			if(destination.type == 'page' || destination.type == 'bookmark') {
1762				var nextHash = destination.value;
1763				var nextUrl = location.pathname + location.search + '#' + nextHash;
1764				history.replaceState('', '', nextUrl);
1765				moveLinkPage(nextHash, interval, destination.type == 'bookmark');
1766			} else if(destination.type == 'url') {
1767				location.href = destination.value;
1768			} else if(destination.type == 'file') {
1769				var $fileLink = $('<a href="javascript:;" attr-flink="' + destination.value + '" style="display:none;"></a>').appendTo('body');
1770				$fileLink.trigger('click');
1771				setTimeout(function() { $fileLink.remove(); }, 0);
1772			} else if(destination.type == 'folder') {
1773				history.replaceState('', '', location.pathname + location.search);
1774				$(window).scrollTop(0);
1775			}
1776			return true;
1777		};
1778
1779		var moveToLoadedTabmenuSection = function(page, interval) {
1780			page = String(page || '').split(',')[0];
1781			if(b.ONE || b.VIEW || !page) return false;
1782			if(loadedTabmenuSectionPage == page) return true;
1783
1784			var $sectionTabmenu = getSiteTabmenuSectionByPage(page);
1785			var $sectionTarget = getRenderOnepagePageBlock(page);
1786			if(!$sectionTabmenu.length || !$sectionTarget.length) return false;
1787			loadedTabmenuSectionPage = page;
1788
1789			var parentMenuUid = $sectionTabmenu.attr('data-parent-menu-uid') || '';
1790			if(window.clTabmenu && typeof window.clTabmenu.activateSectionPage == 'function') {
1791				window.clTabmenu.activateSectionPage(page, parentMenuUid);
1792			}
1793			$('html, body').stop(true, false);
1794			moveLinkPage(page, interval);
1795			return true;
1796		};
1797
1798		var moveScroll = function(interval, loc) {
1799			if(typeof $.cookie('forum_content_view') != 'undefined') {
1800		    	if(window.location.href.indexOf('/forum/view/') == -1) $.removeCookie('forum_content_view', { path: '/', expires: 12 * 60 * 60 * 1000 });
1801		    	return false;
1802		    }
1803			if(applyOnepageDirectMenuDestination(interval)) return;
1804			var currentPage = String(b.PAGE || '').split(',')[0];
1805			if(moveToLoadedTabmenuSection(currentPage, interval)) return;
1806			var this_url = (typeof loc == 'undefined') ? document.URL : loc;
1807			var url = decodeMoveScrollUrl(this_url);
1808		    link = url.split('#').pop();
1809
1810		    if($.inArray(link,b.MENULINK) > -1 && b.ONE && !b.VIEW) {
1811		        moveLinkPage(link,interval);
1812		        $.removeCookie('gallery', { path: '/' });
1813		        $.removeCookie('gallery-item', { path : '/' });
1814		    } else if (url.match(/\@/g)) {
1815		        link = url.split('\@').pop();
1816		        var bookmark_link = url.substr(url.lastIndexOf('/')+1);
1817		        if(link) moveLinkPage(bookmark_link,800,true);
1818		    } else {
1819		    	$(window).scrollTop(0);
1820		    	setTimeout(function() {
1821					if(location.hash) {
1822						var hashArr = location.hash.split('#');
1823						var hash = hashArr[1];
1824						var hashseq = hashArr[2];
1825						if(hash && $('.element[data-name="' + hash + '"]').length) {
1826							var header_check = $("header").attr("data-fh-type");
1827							if (header_check != "sidebar") { var header_height = $("header").outerHeight(true); }	
1828							else {var header_height = 0;}														
1829							// $(window).scrollTop($('.element[data-name="' + hash + '"]').offset().top - header_height);
1830
1831							if($('.tpl-forum-list-cont[data-id="' + hashseq + '"]').length == 0) {
1832								var offset_top = $('.element[data-name="' + hash + '"]').find('.list-item').offset().top;
1833								var win = $(window);
1834								var winHeight = win.height();
1835								win.scrollTop(offset_top - (winHeight / 2) + (header_height / 2));
1836							} else {
1837								var offset_top = $('.tpl-forum-list-cont[data-id="' + hashseq + '"]').closest('.list-item').offset().top - header_height;
1838								var screen_half = ($(window).height() - header_height) / 2;
1839								// $(window).scrollTop(offset_top)
1840								$(window).scrollTop(offset_top - screen_half)
1841							}	
1842
1843							// console.log($('.tpl-forum-list-cont[data-id="72334"]').length);
1844						}
1845					}
1846				});
1847		    }
1848		}
1849
1850		var moveBookmark = function(page, bookmark, interval, target) {
1851			var page_arr = (typeof page == 'undefined') ? new Array() : page.split('\,');
1852			var view = (page_arr.length > 1) ? page_arr[1] : '';
1853
1854			interval = (typeof interval == 'undefined') ? 1200 : interval;
1855			target = (typeof target == 'undefined') ? '' : target;
1856
1857			if( (view != '' && view == b.VIEW && !target) || (view == '' && !b.VIEW && page_arr[0] == b.PAGE && !target) ) {
1858				moveLinkPage(page_arr[0]+bookmark,interval,true);
1859			} else {
1860				var linkUrl = '';
1861				if(b.ONE) {
1862					linkUrl = (view.length>0) ? '/index/view/' + view : '/index';
1863					linkUrl = (!b.PUBLISH) ? '/render' + linkUrl + bookmark : linkUrl + bookmark;
1864				} else {
1865					var url_str = (view.length>0) ? page_arr[0] + '/view/' + view : page;
1866					linkUrl = (URI=='/') ? '/' + url_str + bookmark : URI + '/' + url_str + bookmark;  
1867				}
1868
1869				if(target) {
1870					var openLinkPage = window.open('about:blank');
1871					openLinkPage.location.href=linkUrl;
1872				} else {
1873					var url = new getLocation(linkUrl);		        	
1874					golink(_this,url);
1875					// location.replace(linkUrl);
1876				}
1877
1878			}
1879		}
1880
1881		var requestMenuPageAccess = function(sourcePage, menuUid, callback) {
1882			var menuMap = getRenderMenuUidMap(property.SMENU || []);
1883			var sourceMenu = menuUid ? menuMap[menuUid] : null;
1884			if (!sourceMenu) sourceMenu = getRenderMenuPageMap(property.SMENU || [])[normalizeRenderMenuLinkPage(sourcePage)] || null;
1885			var parentMenu = getTabmenuGroupByPage(sourcePage);
1886			var hasMenuLock = !!((sourceMenu && sourceMenu.lock) || (parentMenu && parentMenu.lock));
1887			if (!hasMenuLock) {
1888				setRenderTabmenuLockPending(sourcePage, false);
1889				callback();
1890				return;
1891			}
1892
1893			var getLockMessage = function(data) {
1894				var lockType = data.lock_type || '';
1895				var errorType = (data.error_data && data.error_data.type) ? '.' + data.error_data.type : '';
1896				var text = $.lang[LANG]['render.menu-lock.' + lockType + '.text'] || $.lang[LANG]['render.menu-lock.denied'];
1897				if (data.menuLockMsg) text = data.menuLockMsg;
1898				if (lockType == 'umlevel' || lockType == 'grade') {
1899					text = $.lang[LANG]['render.menu-lock.' + lockType + '.text' + errorType]
1900						|| (lockType == 'grade' ? $.lang[LANG]['render.menu-lock.umlevel.text' + errorType] : '')
1901						|| text;
1902					if (errorType == '.lowerlevel') {
1903						var requiredValue = lockType == 'grade' ? data.error_data.grade : data.error_data.umlevel;
1904						text = text.replace(/\#/gi, $('<div>').text(String(requiredValue || '')).html());
1905					}
1906				}
1907				return text;
1908			};
1909			var getLockMenuPath = function() {
1910				var names = [];
1911				if (parentMenu && sourceMenu && parentMenu !== sourceMenu) {
1912					names.push(parentMenu.name || getRenderMenuPage(parentMenu));
1913				}
1914				if (sourceMenu) names.push(sourceMenu.name || getRenderMenuPage(sourceMenu));
1915				if (!names.length) names.push(sourcePage);
1916
1917				var path = $.map(names, function(name) {
1918					return '<span class="menu-lock-menu-name">' + $('<div>').text(String(name || '')).html() + '</span>';
1919				}).join('<span class="menu-lock-menu-separator"> &gt; </span><wbr>');
1920				return '<strong class="menu-lock-menu-path">' + path + '</strong>';
1921			};
1922			var applyLockNoticeButtonColor = function(modal) {
1923				var settings = (property.SETTINGS && typeof property.SETTINGS == 'object') ? property.SETTINGS : {};
1924				var buttonColor = settings.menuLockPopupButtonColor || '#4789e7';
1925				modal.addClass('menu-lock-notice-modal');
1926				if (modal[0]) modal[0].style.setProperty('--menu-lock-popup-button-color', buttonColor);
1927				modal.find('.ok-button-dialog').each(function() {
1928					this.style.setProperty('border-color', buttonColor, 'important');
1929					this.style.setProperty('background-color', buttonColor, 'important');
1930				});
1931				return modal;
1932			};
1933
1934			var showAccessDenied = function(data) {
1935				var modal = $(document.body).showModalFlat(
1936					$.lang[LANG]['config.information'],
1937					getLockMessage(data),
1938					true,
1939					false,
1940					'',
1941					'ok',
1942					'',
1943					'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0'
1944				);
1945				applyLockNoticeButtonColor(modal).addClass('menu-lock-denied-modal');
1946			};
1947
1948			var showPasswordModal = function() {
1949				var passwordMessage = $.lang[LANG]['render.menu-lock.password.named-text'] || $.lang[LANG]['render.menu-lock.password.text'];
1950				passwordMessage = passwordMessage.replace('{{menu}}', getLockMenuPath());
1951				var modalContent = '<div class="menu-lock-password">'
1952					+ '<div class="menu-lock-password-content">' + passwordMessage + '</div>'
1953					+ '<div class="form-group">'
1954					+ '<input type="password" class="form-control" data-menu-lock-password placeholder="password">'
1955					+ '<button type="button" class="menu-lock-password-toggle" data-menu-lock-password-toggle aria-pressed="false" aria-label="' + $.lang[LANG]['render.menu-lock.password.show'] + '">'
1956					+ '<svg class="password-show-icon" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M8 3C4.42 3 1.37 5.07 0 8c1.37 2.93 4.42 5 8 5s6.63-2.07 8-5c-1.37-2.93-4.42-5-8-5m0 8.25A3.25 3.25 0 1 1 8 4.75a3.25 3.25 0 0 1 0 6.5m0-5.2A1.95 1.95 0 1 0 8 9.95a1.95 1.95 0 0 0 0-3.9"/></svg>'
1957					+ '<svg class="password-hide-icon" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="m13.83 4.82-.88.88c.69.66 1.26 1.44 1.68 2.3a7.34 7.34 0 0 1-6.64 4.25c-.49 0-.98-.04-1.46-.14l-1.02 1.02q1.215.36 2.49.36a8.75 8.75 0 0 0 8-5.5c-.5-1.2-1.24-2.28-2.17-3.18m-5.38 5.4-1.21 1.21a3.482 3.482 0 0 0 4.17-4.17L10.2 8.46c-.18.88-.87 1.57-1.75 1.76m5.99-7.78-.88-.88-1.8 1.8A8.3 8.3 0 0 0 8 2.5 8.75 8.75 0 0 0 0 8a9.4 9.4 0 0 0 3.13 3.98l-1.57 1.58.88.89zm-8.4 6.64c-.19-.33-.29-.7-.29-1.07 0-1.24 1.01-2.25 2.25-2.25.38 0 .75.1 1.08.29L6.04 9.09ZM1.36 8A7.34 7.34 0 0 1 8 3.75c.96 0 1.92.19 2.81.56l-.83.83a3.43 3.43 0 0 0-1.97-.64c-1.93 0-3.5 1.57-3.5 3.5 0 .71.23 1.4.64 1.97l-1.1 1.1A8.2 8.2 0 0 1 1.37 8"/></svg>'
1958					+ '</button></div>'
1959					+ '<p class="error-text"></p>'
1960					+ '</div>';
1961				var submitting = false;
1962				var modal = $(document.body).showModalFlat(
1963					$.lang[LANG]['config.information'],
1964					modalContent,
1965					true,
1966					true,
1967					function() {
1968						if (submitting) return;
1969						var $input = modal.find('[data-menu-lock-password]');
1970						var password = $.trim($input.val());
1971						if (!password) {
1972							$input.focus();
1973							modal.find('.error-text').text('! ' + $.lang[LANG]['config.enter-password']);
1974							return;
1975						}
1976						submitting = true;
1977						$.post('/template/menuLockController/type/pw_check', {
1978							s: property.SMENU,
1979							sid: property.SID,
1980							page: sourcePage,
1981							pw: password,
1982							publish: property.PUBLISH
1983						}, function(result) {
1984							submitting = false;
1985							if (result && result.result) {
1986								$input.blur();
1987								modal.modal('hide');
1988								setRenderTabmenuLockPending(sourcePage, false);
1989								callback();
1990								return;
1991							}
1992							$input.focus();
1993							modal.find('.error-text').text('! ' + $.lang[LANG]['siteum.regexp.pw.invalid']);
1994						}, 'json').fail(function() {
1995							submitting = false;
1996							modal.find('.error-text').text('! ' + $.lang[LANG]['render.menu-lock.denied']);
1997						});
1998					},
1999					'cancel',
2000					'ok',
2001					'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0',
2002					true,
2003					function() {
2004						modal.find('[data-menu-lock-password]').blur();
2005					},
2006					function() {
2007						modal.find('[data-menu-lock-password]').focus().on('keydown', function(event) {
2008							if (event.keyCode == 13) {
2009								event.preventDefault();
2010								modal.find('.ok-button-dialog').trigger('click');
2011							}
2012						});
2013					}
2014				);
2015				applyLockNoticeButtonColor(modal).addClass('menu-lock-password-modal');
2016				modal.on('click', '[data-menu-lock-password-toggle]', function() {
2017					var $toggle = $(this);
2018					var $input = modal.find('[data-menu-lock-password]');
2019					var isVisible = $input.attr('type') == 'text';
2020					$input.attr('type', isVisible ? 'password' : 'text').focus();
2021					$toggle
2022						.toggleClass('is-visible', !isVisible)
2023						.attr('aria-pressed', !isVisible ? 'true' : 'false')
2024						.attr('aria-label', $.lang[LANG][isVisible ? 'render.menu-lock.password.show' : 'render.menu-lock.password.hide']);
2025				});
2026			};
2027
2028			$.post('/template/menuLockController/type/lock_check', {
2029				s: property.SMENU,
2030				sid: property.SID,
2031				page: sourcePage,
2032				publish: property.PUBLISH
2033			}, function(data) {
2034				if (!data || data.error) {
2035					showAccessDenied(data || {});
2036					return;
2037				}
2038				if (data.result || !data.lock_type) {
2039					setRenderTabmenuLockPending(sourcePage, false);
2040					callback();
2041					return;
2042				}
2043				if (data.lock_type == 'password') {
2044					showPasswordModal();
2045					return;
2046				}
2047
2048				var errorType = (data.error_data && data.error_data.type) ? data.error_data.type : '';
2049				var needsLogin = (data.lock_type == 'umlevel'
2050					&& $.inArray(errorType, ['', 'creatorlink', 'unlikesite']) > -1)
2051					|| (data.lock_type == 'grade'
2052					&& $.inArray(errorType, ['', 'nonmember', 'creatorlink', 'unlikesite']) > -1);
2053				if (!needsLogin) {
2054					showAccessDenied(data);
2055					return;
2056				}
2057
2058				var returnUrl = location.pathname + location.search;
2059				if (property.ONE) returnUrl += '#' + sourcePage;
2060				else returnUrl += location.hash;
2061				var targetUrl = (property.PUBLISH ? '/' : '/render/') + sourcePage;
2062				if (property.ONE) {
2063					targetUrl = b.VIEW
2064						? (property.PUBLISH ? '/#' : '/render/index#') + sourcePage
2065						: location.pathname + location.search + '#' + sourcePage;
2066				}
2067				var loginMessage = $.lang[LANG]['render.menu-lock.login'];
2068				loginMessage = loginMessage.replace('{{menu}}', getLockMenuPath());
2069				var modal = $(document.body).showModalFlat(
2070					$.lang[LANG]['config.information'],
2071					loginMessage,
2072					true,
2073					true,
2074					function() {
2075						try {
2076							sessionStorage.setItem('cl_menu_lock_pending', JSON.stringify({
2077								page: sourcePage,
2078								menu_uid: menuUid,
2079								source_url: location.pathname + location.search + location.hash,
2080								target_url: targetUrl,
2081								publish: property.PUBLISH,
2082								created_at: new Date().getTime()
2083							}));
2084						} catch(storageError) {}
2085						location.href = '/_login?refer=' + encodeURIComponent(returnUrl);
2086					},
2087					'cancel',
2088					'ok',
2089					'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0',
2090					true
2091				);
2092				applyLockNoticeButtonColor(modal).addClass('menu-lock-login-modal');
2093			}, 'json').fail(function() {
2094				showAccessDenied({});
2095			});
2096		};
2097
2098		var getRenderLinkPage = function($link) {
2099			if (!$link || !$link.length) return {page: '', menuUid: '', isMenu: false, destination: null};
2100			var menuMap = getRenderMenuUidMap(property.SMENU || []);
2101			var pageMap = getRenderMenuPageMap(property.SMENU || []);
2102			var menuUid = $link.attr('data-user-link-id')
2103				|| $link.attr('data-menu-link-id')
2104				|| $link.attr('data-menu-uid')
2105				|| $link.closest('[data-menu-link-id]').attr('data-menu-link-id')
2106				|| '';
2107			var sourceMenu = menuUid ? menuMap[menuUid] : null;
2108			var destination = sourceMenu ? resolveRenderMenuDestination(property.SMENU || [], sourceMenu) : null;
2109			if (destination) {
2110				return {
2111					page: destination.type == 'page' ? destination.value : '',
2112					menuUid: getRenderMenuUid(destination.menu) || menuUid,
2113					isMenu: true,
2114					destination: destination
2115				};
2116			}
2117
2118			var rawLink = $link.attr('data-user-link') || $link.attr('data-page') || $link.attr('href') || '';
2119			if (!rawLink || /^(?:javascript:|mailto:|tel:|sms:|callto:|facetime:|skype:|sip:)/i.test(rawLink)) {
2120				return {page: '', menuUid: '', isMenu: false, destination: null};
2121			}
2122			if (/^(?:https?:)?\/\//i.test(rawLink)) return {page: '', menuUid: '', isMenu: false, destination: null};
2123
2124			var page = rawLink;
2125			if (page.indexOf('#') > -1) page = page.split('#').pop();
2126			else {
2127				page = page.split('?')[0].replace(/^\/render\/?/i, '');
2128				var renderBase = String(property.URL || '').replace(/^\/+|\/+$/g, '');
2129				if (renderBase && page.replace(/^\/+/, '').indexOf(renderBase + '/') === 0) {
2130					page = page.replace(/^\/+/, '').substr(renderBase.length + 1);
2131				}
2132			}
2133			page = normalizeRenderMenuLinkPage(page);
2134			var targetMenu = pageMap[page] || null;
2135			if (targetMenu) {
2136				var targetDestination = resolveRenderMenuDestination(property.SMENU || [], targetMenu);
2137				if (targetDestination && targetDestination.type == 'page') {
2138					return {
2139						page: targetDestination.value,
2140						menuUid: getRenderMenuUid(targetDestination.menu) || getRenderMenuUid(targetMenu),
2141						isMenu: true,
2142						destination: targetDestination
2143					};
2144				}
2145			}
2146			return {
2147				page: targetMenu ? getRenderMenuPage(targetMenu) : page,
2148				menuUid: getRenderMenuUid(targetMenu),
2149				isMenu: !!targetMenu,
2150				destination: null
2151			};
2152		};
2153
2154		var moveRenderMenuLinkByClick = function(linkElement) {
2155			var $link = $(linkElement);
2156			if (!$link.length || $.inArray($link.attr('target'), ['_blank', 'blank']) > -1) return false;
2157
2158			var linked = getRenderLinkPage($link);
2159			if (linked.destination && linked.destination.type != 'page') {
2160				if (linked.destination.type == 'url') {
2161					if ($link.attr('target') == '_blank') window.open(linked.destination.value);
2162					else location.href = linked.destination.value;
2163				} else if (linked.destination.type == 'bookmark') {
2164					menuClickMove = true;
2165					moveLinkPage(linked.destination.value, 1200, true, true);
2166				} else if (linked.destination.type == 'file') {
2167					var $fileLink = $('<a href="javascript:;" attr-flink="' + linked.destination.value + '" style="display:none;"></a>').appendTo('body');
2168					$fileLink.trigger('click');
2169					setTimeout(function() { $fileLink.remove(); }, 0);
2170				}
2171				return true;
2172			}
2173			var page = linked.page;
2174			var parentMenu = getTabmenuGroupByPage(page);
2175			if (!page || !linked.isMenu) return false;
2176
2177			var parentMenuUid = getRenderMenuUid(parentMenu);
2178			var $tabmenu = $link.closest('.cl-tabmenu');
2179			if (!$tabmenu.length) $tabmenu = getRenderTabmenuBlocksByPage(page).filter(':not([data-tabmenu-sticky-clone])').first();
2180			var tabMode = $tabmenu.attr('data-tabmenu-mode') || 'page';
2181			var movePage = function() {
2182				if (parentMenu && tabMode == 'section' && getRenderOnepagePageBlock(page).length > 0) {
2183					if (window.clTabmenu && typeof window.clTabmenu.activateSectionPage == 'function') {
2184						window.clTabmenu.activateSectionPage(page, parentMenuUid);
2185					}
2186					menuClickMove = true;
2187					moveLinkPage(page, undefined, undefined, true);
2188					return;
2189				}
2190
2191				if (!property.ONE) {
2192					var href = property.PUBLISH
2193						? '/' + encodeURIComponent(page)
2194						: '/render/' + encodeURIComponent(page);
2195					markPageClickMove(page);
2196					golink(_this, new getLocation(href));
2197					return;
2198				}
2199
2200				if (parentMenu && window.clTabmenu
2201					&& typeof window.clTabmenu.activateOnepagePage == 'function'
2202					&& window.clTabmenu.activateOnepagePage(page, parentMenuUid)
2203				) {
2204					menuClickMove = true;
2205					moveLinkPage(page, undefined, undefined, true);
2206					return;
2207				}
2208
2209				if (getRenderOnepagePageBlock(page).length > 0) {
2210					menuClickMove = true;
2211					moveLinkPage(page, undefined, undefined, true);
2212				}
2213			};
2214
2215			requestMenuPageAccess(page, linked.menuUid, movePage);
2216			return true;
2217		};
2218		window.moveRenderMenuLinkByClick = moveRenderMenuLinkByClick;
2219
2220		var moveLinkPage = function(link, interval, isblock, lockChecked) {
2221			if (/^@/.test(link)) {
2222				resolveMenuBookmark(link, property.SID, property.PUBLISH).done(function(bookmark) {
2223					var ownerPage = bookmark.page.split(',')[0];
2224					var owner = getRenderMenuPageMap(property.SMENU || [])[normalizeRenderMenuLinkPage(ownerPage)];
2225					requestMenuPageAccess(ownerPage, getRenderMenuUid(owner), function() {
2226						var anchor = '@' + String(link).split('@').pop();
2227						if ($('.element[data-bookmark="' + anchor.substring(1) + '"]').length) {
2228							moveLinkPage(bookmark.value, interval, true, true);
2229						} else {
2230							markPageClickMove(bookmark.page);
2231							moveBookmark(bookmark.page, anchor, interval);
2232						}
2233					});
2234				});
2235				return;
2236			}
2237		    link = decodeURIComponent(link);
2238			if(typeof interval == 'undefined') interval = 1200;
2239			if(typeof isblock == 'undefined') isblock = '';
2240
2241			var isBookmark = false;
2242			var bookmark_arr = new Array();
2243			if(link.match(/\@/g)) {
2244				isBookmark = true;
2245				bookmark_arr = link.split('\@');
2246
2247				var check_link = true;
2248				var is_visible_menu = false;
2249				$.each(b.SMENU, function (idx, obj) {
2250					if(is_o_page == obj.name.replace(/ /g,'-')) {
2251						if(!obj.link) check_link = false;
2252						if(obj.display == 'on') is_visible_menu = false;
2253					}
2254					if(obj.children) {
2255						$.each(obj.children, function (i, v){
2256							if(is_o_page == v.name.replace(/ /g,'-')) {
2257								if(!v.link) check_link = false;
2258								if(v.display == 'on') is_visible_menu = false;
2259							}
2260						});
2261					}
2262				});
2263
2264				var is_here = ($('.element[data-bookmark="' + bookmark_arr[1] + '"]').length > 0 ) ? true : false;
2265				var is_page = (b.PAGE.toLowerCase() == bookmark_arr[0].toLowerCase() || b.VIEW && b.VIEW == bookmark_arr[0]) ? true : false;
2266				var is_o_page = (bookmark_arr[0].indexOf(',') > -1 && !b.VIEW) ? bookmark_arr[0].substring(0, bookmark_arr[0].indexOf(',')) : (b.VIEW) ? 'index' : bookmark_arr[0];
2267				// var is_visible_menu = ($.inArray(is_o_page,b.MENULINK)>-1) ? true : false;
2268				// var check_link = ( $('#tpl-menu li a[href*="'+is_o_page+'"]').length > 0 && $('#tpl-menu li a[href*="'+is_o_page+'"]').text().trim().replace(/ /gi,'-') == is_o_page ) ? false : true;
2269				var is_link = (check_link && is_visible_menu && is_o_page != 'INTRO') ? true : false;
2270				var is_visible = (check_link && is_visible_menu && is_o_page != 'INTRO') ? true : false;
2271
2272				if( ( !is_visible_menu && is_o_page!='index' ) ||
2273					( /*!is_page &&*/ ( is_link || is_visible ) ) ||
2274					( is_page && !is_here )
2275				)  {
2276					if(is_visible_menu == false) ;
2277					else return false;
2278				}
2279				link = 'element[data-bookmark="' + bookmark_arr[1] + '"]';
2280
2281			}
2282
2283			var pageName = isBookmark ? '' : link.replace(/^link-to-/, '');
2284			var navigationPage = isBookmark ? String(bookmark_arr[0] || '').split(',')[0] : pageName;
2285			var pageMenu = !isBookmark
2286				? getRenderMenuPageMap(property.SMENU || [])[normalizeRenderMenuLinkPage(pageName)] || null
2287				: null;
2288			if (!isBookmark && !lockChecked && pageMenu) {
2289				requestMenuPageAccess(pageName, getRenderMenuUid(pageMenu), function() {
2290					moveLinkPage(link, interval, isblock, true);
2291				});
2292				return;
2293			}
2294			var tabmenuMoveTarget = null;
2295			if (navigationPage && window.clTabmenu) {
2296				if (typeof window.clTabmenu.activateOnepageNavigationPage == 'function') {
2297					window.clTabmenu.activateOnepageNavigationPage(navigationPage);
2298				} else if (typeof window.clTabmenu.activateOnepagePage == 'function') {
2299					window.clTabmenu.activateOnepagePage(navigationPage);
2300				}
2301				if (typeof window.clTabmenu.getOnepageNavigationTarget == 'function') {
2302					tabmenuMoveTarget = window.clTabmenu.getOnepageNavigationTarget(pageName);
2303				}
2304			}
2305			var moveTarget = isBookmark
2306				? $('.' + link)
2307				: (tabmenuMoveTarget ? $(tabmenuMoveTarget) : getRenderOnepagePageBlock(pageName));
2308			if(moveTarget.length == 0) return;
2309
2310			if($.clnav.check()) {
2311				goToElement(moveTarget.first());
2312			} else {
2313				// oldver
2314				var header_fixed = ($('.dsgn-body').width() < 769) ? $('.el-menu .navbar-header').height() - 1 : $('#tpl-menu').height();
2315				if ($('header').hasClass('navbar-fheader')) header_fixed = $('header.navbar').outerHeight() - 1;
2316
2317				var offset = ($('.dsgn-body').hasClass('sidebar')) ? 0 : -header_fixed;
2318				if ($('header.navbar').hasClass('disableOffset') && !moveTarget.first().hasClass('el_0')) offset = 0;
2319				offset = (window.innerWidth > 768) ? offset : -header_fixed;
2320
2321				var sTop = moveTarget.offset().top + offset;
2322				if(moveTarget.is('[data-aos]') && !moveTarget.hasClass('aos-animate')) {
2323					const tr = moveTarget.css('transform');
2324					let moveY = 0;
2325					if (tr && tr !== "none") {
2326						const vals = tr.match(/-?\d+\.?\d*/g);
2327						moveY = parseFloat(vals[13] || vals[5] || 0); // 이미 음수/양수 포함됨
2328
2329						sTop -= moveY;
2330					}
2331				}
2332				sTop = (isAosBlock && moveTarget.hasClass('el_0') == false && $('.menu-logo-top').length > 0 && $('.menu-logo-top').css('display')=='block') ? sTop + $('.menu-logo-top').outerHeight() : sTop;
2333
2334				var duration = (typeof $('#tpl-menu').attr('data-duration') != 'undefined') ? parseInt($('#tpl-menu').attr('data-duration')) : ((isBookmark) ? 500 : 1000);
2335				if(clCheckBrowser('safari') && clCheckBrowser('mobile') || moveTarget.hasClass('el_0')) duration = 0;
2336				$('html, body').stop(true, false).animate({
2337					scrollTop: sTop
2338				}, duration, 'easeInOutQuart', function() {
2339					if(isAosBlock) {
2340						$.each($('.element'), function() {
2341							var aos = $(this).attr('data-aos-ch');
2342							$(this).attr('data-aos',aos);
2343							$(this).removeAttr('data-aos-ch');
2344						});
2345					}
2346				});
2347
2348				var menuStr = (!isBookmark) ? pageName : bookmark_arr[0];
2349				setTimeout(function() {
2350					$('header #tpl-menu li a[href="#' + menuStr + '"]').closest('li').addClass('active').siblings().removeClass('active');
2351					if($('#mobile-nav #tpl-menu li').length) $('#mobile-nav #tpl-menu li a[href="#' + menuStr + '"]').closest('li').addClass('active').siblings().removeClass('active');
2352				},1100);
2353			}
2354		}
2355
2356		$('.dsgn-body .cl-tabmenu .tabmenu-btn[data-page], .tabmenu-sticky-rail .cl-tabmenu .tabmenu-btn[data-page]').live('click', function(e) {
2357			if (property.VIEW) return;
2358			if ($.inArray($(this).attr('target'), ['_blank', 'blank']) > -1) return;
2359
2360			e.preventDefault();
2361			e.stopImmediatePropagation();
2362			moveRenderMenuLinkByClick(this);
2363			return false;
2364		});
2365
2366		var resumeMenuLockPending = function(attempt) {
2367			var pending = null;
2368			try {
2369				pending = JSON.parse(sessionStorage.getItem('cl_menu_lock_pending') || 'null');
2370			} catch(storageError) {}
2371			if (!pending || !pending.page || new Date().getTime() - Number(pending.created_at || 0) > 600000) {
2372				try { sessionStorage.removeItem('cl_menu_lock_pending'); } catch(storageError) {}
2373				return;
2374			}
2375			if (!property.UMEMBER || property.UMEMBER.check_login !== true) return;
2376
2377			var $pendingLink = $('[data-menu-link-id], [data-user-link-id], .tabmenu-btn[data-menu-uid][data-page]').filter(function() {
2378				if (pending.menu_uid && ($(this).attr('data-menu-link-id') == pending.menu_uid
2379					|| $(this).attr('data-user-link-id') == pending.menu_uid
2380					|| $(this).attr('data-menu-uid') == pending.menu_uid)
2381				) return true;
2382				return $(this).attr('data-page') == pending.page;
2383			}).first();
2384			var onepageTargetReady = !property.ONE || getRenderOnepagePageBlock(pending.page).length > 0;
2385			if ((!$pendingLink.length || !onepageTargetReady) && attempt < 20) {
2386				setTimeout(function() { resumeMenuLockPending(attempt + 1); }, 250);
2387				return;
2388			}
2389			try { sessionStorage.removeItem('cl_menu_lock_pending'); } catch(storageError) {}
2390			if (!$pendingLink.length) {
2391				$pendingLink = $('<a>')
2392					.attr('data-menu-uid', pending.menu_uid || '')
2393					.attr('data-page', pending.page);
2394			}
2395			moveRenderMenuLinkByClick($pendingLink[0]);
2396		};
2397		setTimeout(function() { resumeMenuLockPending(0); }, 300);
2398
2399			var getParent = function(parent,id,page) {
2400		    if(id) {
2401		    	parent = (parent == 'forum') ? parent : 'project';
2402				$.ajax({
2403					url:'/template/get/parent/' + parent + '/id/' + id + '/sid/' + _this.b.SID + '/page/' + encodeURIComponent(page) + _this.b.param,
2404					type:'get',
2405					async:false,
2406                	cache: false,
2407					dataType:'json',
2408					success:function(data) {
2409						property.PRODINFO = (data.prod_onoff == "on") ? data.PRODINFO : '';
2410						_this.b.PARENT = data.PARENT;
2411						_this.b.COUNT = data.COUNT;
2412					}
2413				});
2414		    } else {
2415				property.PRODINFO = "";
2416				_this.b.PARENT = {};
2417				_this.b.COUNT = 0;
2418		    }
2419		}
2420
2421		var showPageCallback = function(func,callback) {
2422		    func(b.MCSS, b.MSTYLE, b.MTAG, true);
2423		    if(typeof callback=='function') {
2424		    	callback();
2425		    }
2426		}
2427
2428		var showPage = function (css, style, tag, prop) {
2429			if($('.fmcss').length > 0) $('.fmcss').remove();
2430		    $.each(style.children,function(k,v) {
2431		        if(k!='.dsgn-body') {
2432		            delete style.children[k];
2433		        }
2434		    });
2435    		elFooter();
2436
2437			var isSidebar = $('.el-menu > header').hasClass('sidebar');
2438			var isHeaderOldVer = !$.clnav.check();
2439			if(isHeaderOldVer) {
2440				if(b.HEADER && b.PARENT.mode == 'shopping') b.HEADER = false;
2441				if(b.HEADER && !isSidebar) $('header.navbar').addClass('transparent');
2442	
2443				header_fixed = $('header.navbar').height();
2444				if($('header.navbar').css('background-color')=='rgba(0, 0, 0, 0)'
2445					&& $('header.navbar').css('background-image')=='none'
2446				) {
2447					$('header.navbar').css('background-color',$('dsgn-body').css('background-color'));
2448				}
2449			}
2450
2451		    if(b.SETTINGS.sitePermit === 3) {
2452		    	var checkSiteLock = isSitePasswordLock();
2453		    } 
2454
2455		    var is_lock_block = 'active';
2456			isMenuLock(function() {
2457				if(b.ISLOCK != 'true') elPush(prop);
2458				else {
2459					hidePageContentLoading();
2460					$('.el-footer').css('visibility', 'visible');
2461					$.processOFF();
2462				}
2463			});
2464
2465			// menu active
2466			/* 190710 -  menu or sub-menu 일부 같을때 첫번째 메뉴에 active error 생겨서 주석 처리. */
2467			// if(b.PARENT.page) {
2468			// 	$('#tpl-menu li').find('a:contains("' + b.PARENT.page + '")').parent().addClass('active');
2469			// } else {
2470			// 	if(b.ONE) {
2471			// 		if(b.SMENU[0].display == 'off') $('#tpl-menu li').first().addClass('active');
2472			// 	} else if(b.PAGE) {
2473			// 		$('#tpl-menu li').find('a:contains("' + b.PAGE + '")').parent().addClass('active');
2474			// 	}
2475			// };
2476
2477		    RENDER.setLoginout(b.LOGINOUT, b.SID, b.PUBLISH, b.PROFILEIMG);
2478		    $('body,html').animate({scrollTop: 0}, 300,'easeInOutQuart');
2479		}
2480
2481		var loadPush = function(data) {
2482			// console.log(' page draw 02:: loadPush');
2483			window._blockMasonryResizeTargets = [];
2484			$('body').removeAttr('data-gjs');
2485			$('.dsgn-body .tabmenu-auto-block, .dsgn-body .element[data-type="tabmenu"]').not('[data-tabmenu-page-preserve]').each(function() {
2486				var $tabmenu = $(this);
2487				var $wrapper = $tabmenu.closest('.elem');
2488				if($wrapper.is('[data-tabmenu-page-preserve]')) return true;
2489				if($wrapper.length) $wrapper.remove();
2490				else $tabmenu.remove();
2491			});
2492
2493			var deferred = $.Deferred();
2494			var pageID = b.PAGE.split(','),
2495				chgBG = false,
2496				tmpTag = '',
2497				currentPAGE = b.PAGE,
2498				default_t_css = '', default_m_css = '';
2499
2500			var is_templates = checkTemplateSite(b.SID);
2501			
2502			var checkGalleryView = (b.VIEW && b.PAGE.match(/^forum,/g) === null) ? true : false,
2503				checkShoppingView = (b.VIEW && b.PARENT.mode == 'shopping') ? true : false,
2504				page_pos = 0,
2505				site_settings = (typeof b.SETTINGS != 'undefined' && b.SETTINGS) ? b.SETTINGS : {};
2506
2507			if($('body').hasClass('openPopupBanner') && b.MENULINK[0] != currentPAGE) {
2508				$.siteBanner.init(false,true);
2509			}
2510			if(typeof $.clnav.s != 'undefined') $.clnav.init();
2511
2512	        $('#el-empty').empty();
2513	        $('.gallery-popup, .psearch-block').remove();
2514	        b.COUNT = data.length;
2515
2516			var check_modoo = $('.dsgn-body').hasClass('modoo') ? true : false,
2517				fl_data = {};
2518				
2519			if(check_modoo) {
2520				fl_data = draw_floating();
2521			}
2522
2523			function drawData(idx, val) {
2524				// console.log(`drawData(${idx}, ${val})`);
2525				page_pos += 1;
2526				var tabmenuSectionPage = val.tabmenu_section_page || '';
2527				var elementPage = tabmenuSectionPage || currentPAGE;
2528				var tag = htmlspecialchars_decode(val.eltag,'ENT_QUOTES');
2529				var settings = (typeof val.elsettings != 'undefined' && val.elsettings) ? $.parseJSON(val.elsettings) : {};
2530				var block_lang = (typeof settings.blocklang != 'undefined' && settings.blocklang) ? settings.blocklang : LANG;
2531				var checkGalleryListSample = false;
2532				var checkGalleryListEmpty = true;
2533				var fontload = [];
2534
2535				if(val.type == 'project' && val.eltag.charAt(0) == '\<') tag = val.eltag;
2536
2537				if(typeof val.fonts != 'undefined') {
2538					$.each(val.fonts, function(i,v) {
2539						if(b.ELFONTS.indexOf(i) < 0 && v) {
2540							b.ELFONTS.push(i);
2541							$('#loadfonts').append(v);
2542						}
2543					});
2544				}
2545				if(typeof val.webfonts != 'undefined' && val.webfonts) {
2546					$.each(val.webfonts, function(i2,v2) {
2547						if(b.ELFONTS.indexOf(i2) < 0 && v2) {
2548							b.ELFONTS.push(i2);
2549							WebFont.load({ google : { families : [ v2 ], display:'swap' }});
2550						}
2551					})
2552				}
2553
2554				if($.inArray(val.type, ['gallery','shopping']) > -1) {
2555					if($('#el-empty').length === 0) $('body').append('<div id="el-empty" class="opacity: 0;"></div>');
2556					$('#el-empty').append($(tag));
2557					$('#el-empty').find('[data-loop="true"]').html('');
2558
2559					var nodes = $(tag).find('[data-loop="true"]').children('.grid'),
2560						p = $('#el-empty').children(),
2561						g = p.clone().removeClass().addClass('galleryPL'+val.seq).addClass('gallery-popup'),
2562						i = [],
2563						view = $(tag).find('[data-loop="true"]').data('view'),
2564						g_number = $(tag).find("[data-loop='true']").data('gallery-no'),
2565						total = 0;
2566
2567					var checkLoadmoreInLoop = ($(tag).find('[data-loop="true"] .loadmore-wrap').length) ? true : false;
2568					var glm = $(tag).find('.loadmore-wrap');
2569
2570					$('#el-empty').after(g);
2571					$(g).after('<div class="gallery-empty"></div>');
2572
2573					galleryEL[val.seq] = {
2574						'seq' : val.seq,
2575						'elname' : val.elname,
2576						'eltag' : tag,
2577						'folder' : val.folder,
2578						'mode' : val.mode,
2579						'elsettings' : val.elsettings,
2580						'feature' : val.feature,
2581						'type' : val.type,
2582						'type2' : val.type2,
2583						'searches' : val.searches
2584					};
2585
2586					if(typeof view == 'undefined') view = 10;
2587					var cookie_page = 1,
2588						cookie_view = view,
2589						cookie_gallery_category = '',
2590						is_gc_cookie = (typeof $.cookie('gallery-category-'+val.seq) != 'undefined' && $.cookie('gallery-category-'+val.seq).length > 0) ? true : false;
2591            		var cookie_gallery_orderby = 'recent';
2592
2593					var category_onoff = (typeof settings.category_display != 'undefined' && settings.category_display) ? settings.category_display : 'OFF';
2594					var gallery_sort = (typeof settings.gallery_sort != 'undefined' && settings.gallery_sort) ? settings.gallery_sort : 'default';
2595					if(val.mode != 'shopping' && gallery_sort == 'product') gallery_sort = 'default';
2596					// var adultonly_onoff = (typeof settings.adult_only != 'undefined' && settings.adult_only) ? settings.adult_only : 'OFF';
2597					
2598					if(typeof $.cookie('loadmore-' + val.seq) != 'undefined' && $.cookie('loadmore-' + val.seq).length > 0) {
2599						cookie_page = $.cookie('loadmore-'+val.seq);
2600						cookie_gallery_category = (typeof $.cookie('gallery-category-'+val.seq) != 'undefined') ? $.cookie('gallery-category-'+val.seq) : '';
2601	                    cookie_gallery_orderby = (typeof $.cookie('gallery-orderby-' + val.seq) != 'undefined') ? $.cookie('gallery-orderby-' + val.seq) : '';
2602						cookie_view = cookie_page * view;
2603					} else { 
2604						var checkCateHomeHide = (category_onoff == 'ON' &&
2605												typeof settings.category != 'undefined' && settings.category && 
2606												typeof settings.category_home_hide != 'undefined' && settings.category_home_hide) ? true : false;
2607						if(checkCateHomeHide) {
2608							var gc = settings.category.replace(/\|/g,'').split(',');
2609							cookie_gallery_category = gc[0];
2610							is_gc_cookie = true;
2611
2612							$.cookie('gallery-catehome-' + val.seq, cookie_gallery_category, { path : '/', expires: 12 * 60 * 60 * 1000 });
2613						}
2614					}
2615					
2616					if(val.seq == 'all_products') {
2617					// 	cookie_page = (typeof $.cookie('gallery-page-all_products') !== 'undefined' && $.cookie('gallery-page-all_products') != '')? $.cookie('gallery-page-all_products') : 1;
2618						cookie_gallery_category = getAllProductsSortVal(settings);
2619					// 	cookie_view = cookie_page * view;
2620					} else {
2621						if(!property.VIEW) $.removeCookie('gallery-page-all_products', { path: '/' });
2622					}
2623					
2624					$.cookie('gallery-page-' + val.seq, cookie_page, { path : '/', expires: 12 * 60 * 60 * 1000 });
2625					$.cookie('gallery-category-' + val.seq, cookie_gallery_category, { path : '/', expires: 12 * 60 * 60 * 1000 });
2626	                $.cookie('gallery-orderby-' + val.seq, cookie_gallery_orderby, { path: '/', expires: 12 * 60 * 60 * 1000 });
2627					$.removeCookie('loadmore-' + val.seq, { path : '/' });  
2628
2629					var checkGallerySVG = ($(tag).find('.gimg-svg-wrap').length > 0) ? true : false,
2630						checkGFrameTitleOFF = (val.mode == 'gallery' && (typeof settings.gframe_title_visible != 'undefined' && settings.gframe_title_visible == 'OFF')) ? true : false;
2631
2632					var checkUseComment = checkUseCommentFunc(val.mode, val.eltag);
2633					var checkUseLike = checkUseLikeFunc(val.mode, val.eltag);
2634
2635					var uri = getSearchURL();
2636					if (isObjectEmpty(uri) && _this.b.LUX && val.mode == 'shopping') {
2637						uri = val.searches.uri;
2638					}
2639					// if(uri.category_no == '') {
2640					// 	uri.category_no = (typeof settings.lux_category_no != 'undefined') ? settings.lux_category_no : '';
2641					// }
2642					
2643					var res;
2644					
2645					$.ajax({
2646						url: '/template/gallery/list/pid/' + val.seq + '/sid/' + b.SID + '/spage/' + elementPage + '/view/' + cookie_view + param,
2647						data: { g_mode: val.mode,  visible: true, sfl: 'category', stx: cookie_gallery_category, uri : uri, only : val.only_category, orderby: cookie_gallery_orderby},
2648						dataType: 'json',
2649						type: 'POST',
2650						async: false,
2651						cache: false,
2652						success: function (data) {
2653							var check_only_cate = (typeof data.only_category != 'undefined' && data.only_category === true) ? true : false;
2654							if(check_only_cate) {
2655								localStorage.setItem('searches',JSON.stringify(new Array(val.searches.uri[0])));
2656							}
2657	
2658							res = data;
2659							$.each(data.list, function (idx, v) {
2660								i.push(v);
2661							});
2662							total = (typeof data.total.list_total == 'undefined') ?  data.total : data.total.list_total;
2663							cookie_view = ( cookie_view > total ) ? total : cookie_view;
2664							// cookie_view = (cookie_view < total) ? cookie_view : total;
2665
2666							if( total > 0 ) checkGalleryListEmpty = false;
2667							if( i.length>0 || (i.length==0 && is_gc_cookie) ) {
2668								var loop_count = nodes.length, item_index = 0;
2669								var elem = [];
2670								$.each(data.list,function(index,v) {
2671									loop_pos = index%loop_count;
2672									c = nodes[loop_pos];
2673                                	var isTitle = (v.title.length > 0) ? true:false;
2674
2675									$(c).find('.non_text').removeClass('non_text');
2676									if(val.mode != 'shopping') {
2677										if(v.title.length==0) $(c).find('.figure.title').removeClass('non_text').addClass('non_text');
2678										if(v.caption.length==0) $(c).find('.figure.caption').removeClass('non_text').addClass('non_text');
2679									}
2680
2681									v.title = (v.title.length>0) ? v.title : $.lang[block_lang]['editor.block.gallery.sample.title'];
2682									v.caption = (v.caption.length>0) ? v.caption : $.lang[block_lang]['editor.block.gallery.sample.caption'];
2683
2684									$(c).addClass('gallery-item').attr('data-index',index).attr('data-seq',v.seq);
2685									
2686									var vgsettings = (typeof v.gsettings != 'undefined' && v.gsettings) ? $.parseJSON(v.gsettings) : {},
2687										img_path = (typeof vgsettings['storage'] != 'undefined') ? vgsettings['storage'] : _this.b.RESOURCE + '/' + _this.b.SID + '/',
2688										img_original = (typeof vgsettings['storage'] != 'undefined') ? img_path + '1920/' : img_path;
2689
2690									var folder = (val.folder == 0) ? '' : val.folder + '/',
2691										src = getServeImage(v.image,val.folder,img_path),
2692										src_s0 = getServeImage(v.image,'0',img_path);
2693									if($(c).find('img').length > 0) $(c).find('img').attr('src',src);
2694									if(val.mode == 'shopping') {
2695										if($(c).find('img').length > 0) $(c).find('img').attr('alt',v.title);
2696									} else {										
2697 									    alt_replace	= v.alt.replace(/\s+|\n+/g, '-');  
2698		    	          				alt_replace.replace(/-+/g, '-')	
2699										if($(c).find('img').length > 0) $(c).find('img').attr('alt',alt_replace);										
2700									}
2701									ensureGalleryResponsiveImageClass($(c));
2702									if($(c).find('.g-img').length > 0) $(c).find('.g-img').css('background-image', 'url('+src+')');
2703
2704									if(checkGallerySVG) {
2705										var gimgSVG = $(c).find('.gimg-svg-wrap svg');
2706										gimgSVG.find('pattern').attr('id','gimgSvg_'+val.elname+'_'+index);
2707										gimgSVG.find('image').attr('xlink:href', src);
2708										gimgSVG.find('polygon, path').attr('fill', 'url(#gimgSvg_'+val.elname+'_'+index+')');
2709									}
2710
2711									var glink = (typeof vgsettings['glink'] != 'undefined' && vgsettings['glink']) ? vgsettings['glink'] : '',
2712										glink_target = (typeof vgsettings['glink_target'] != 'undefined' && vgsettings['glink_target']) ? vgsettings['glink_target'] : '';
2713
2714									if(glink) {
2715										if(glink.match(/^\@/g) !== null) {															// link-type: link-bookmark ==> a[attr-bookmark]
2716											var bookmark_seq = glink.replace(/^\@/g,'');
2717											if(typeof _this.b.SETTINGS.blockBookmarkList == 'undefined' || typeof _this.b.SETTINGS.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
2718												glink = '';
2719												glink_target = '';
2720											}
2721										} else if(glink.match(/^flink\@[0-9]/gi) !== null) {										// link-type: link-file     ==> a[attr-flink]
2722											glink_target = '';
2723										} else if(isRenderMenuPageLink(glink, _this.b.MENULIST)) {	// link-type: link-menu     ==> a[data-user-link]
2724										} else {																					// link-type: link-out      ==> a[attr-link]
2725											if(checkBase64Encode(glink)) glink = Base64.decode(glink);
2726										}
2727									}
2728
2729									var entry =	(property && property.CONTENTS && property.CONTENTS['el' + v.pid]) || (property && property.CONTENTS && property.CONTENTS[String(v.pid)]) || null;
2730									var elsettingsRaw = entry && entry.element ? entry.element.elsettings : null;
2731									var elsettingsObj = elsettingsRaw;
2732
2733									if (typeof elsettingsRaw === 'string') {
2734										try { elsettingsObj = JSON.parse(elsettingsRaw); }
2735										catch (e) { console.error('[ERR] elsettings JSON 파싱 실패:', e, elsettingsRaw); elsettingsObj = {}; }
2736									}
2737
2738									var gallery_page_chmod = elsettingsObj && elsettingsObj.gallery_page_chmod || null;
2739									var umgrade = property && property.UMGRADE ? (property.UMGRADE.seq || property.UMGRADE.grade_id || null) : null;
2740									if (typeof gallery_page_chmod === 'string') {
2741										try { gallery_page_chmod = JSON.parse(gallery_page_chmod); }
2742										catch (e) { gallery_page_chmod = gallery_page_chmod ? gallery_page_chmod.split(',') : []; }
2743									}
2744									gallery_page_chmod = $.isArray(gallery_page_chmod) ? $.map(gallery_page_chmod, function(v) { return String(v); }) : [];
2745									umgrade = (umgrade !== null && typeof umgrade != 'undefined') ? String(umgrade) : null;
2746
2747									// console.log({ gallery_page_chmod, umgrade });
2748
2749									$(c).find('a').removeAttr('data-gallery').removeAttr('data-user-link').removeAttr('attr-bookmark').removeAttr('attr-link').removeAttr('attr-flink');
2750									$(c).removeClass('noneShoppingGrade').removeAttr('data-shopping-grade-msg');
2751									if (isShoppingGradePriceHidden(v) && property['SITEUM'] >= 1) {
2752										$(c).addClass('gallery-item').addClass('nonePrice');
2753										$(c).find('a').attr('href', '#');
2754									} else {
2755										if(isShoppingGradeBlocked(v, val.seq == 'all_products' ? settings : elsettingsObj, property)) { //쇼핑등급
2756											$(c).addClass('gallery-item').addClass('noneShoppingGrade');
2757											$(c).attr('data-shopping-grade-msg', getShoppingGradeBlockedMessage(v));
2758											$(c).find('a').attr('href', '#');
2759										} else {
2760											if(glink) {
2761												var glink_val = makeLinkUrl(glink, b.ONE, b.VIEW);
2762												$(c).find('a').attr('href',glink_val);
2763
2764												if(glink.match(/^\@/g)) {
2765													$(c).find('a').attr('attr-bookmark',glink.replace(/^\@/g,''));
2766												} else if(glink.match(/^flink\@[0-9]/g) !== null) {
2767													$(c).find('a').attr('attr-flink',glink.replace(/^flink\@/g,''));
2768												// IE ERROR_includes__H.20210603
2769												// } else if(_this.b.MENULIST.includes(glink.replace(/ /g,'-'))) {
2770												} else if(isRenderMenuPageLink(glink, _this.b.MENULIST)) {
2771													$(c).find('a').attr('data-user-link',glink_val);
2772												} else {
2773													$(c).find('a').attr('attr-link',glink);
2774												}
2775											} else {
2776												if (val.mode == 'gallery') {
2777													src_s0 = src_s0 + '?gpos='+v.pos;
2778
2779													$(c).find('a').attr('href', src_s0);
2780													$(c).find('a').attr('data-gallery', '#gframe-' + val.seq);
2781												} else {
2782													if(val.seq == 'all_products') {
2783														$(c).find('a').attr('href', v.product_url);
2784													} else {
2785														if(_this.b.LUX) $(c).find('a').attr('href', ((_this.b.URL=='/') ? '' : _this.b.URL) + '/_product/' + v.seq);
2786														else $(c).find('a').attr('href', ((_this.b.URL=='/') ? '' : _this.b.URL) + '/' + elementPage + '/view/' + v.seq);
2787							
2788														// $(c).find('a').attr('href', ((URI=='/') ? '' : URI) + '/' + b.PAGE + '/view/' + v.seq);
2789													}		
2790												}
2791											}
2792										}
2793									}
2794
2795									if(glink_target == '_blank') $(c).find('a').attr('target','_blank');
2796									else $(c).find('a').removeAttr('target');
2797
2798									if(checkGFrameTitleOFF || !isTitle) $(c).find('a').attr('data-title', '');
2799									else $(c).find('a').attr('data-title', v.title);
2800
2801									// if(adultonly_onoff == 'ON') $(c).addClass('adultonly');
2802
2803									// caption
2804									var ftitle = $(c).find('h5.figure'),
2805										fcaption = $(c).find('p.figure').not('.comment'),
2806										fdatetime = $(c).find('.figure.datetime'),
2807										fhashtag = $(c).find('.figure.hashtag'),
2808										fbrand = $(c).find('.figure.brand'),
2809										fprice = $(c).find('.figure.price'),
2810										freview = $(c).find('.figure.review'),
2811										fcomment = $(c).find('.figure.comment'),
2812										flike = $(c).find('.figure.like'),
2813										fbasket = $(c).find('.figure.basket');
2814
2815									$(c).find('figcaption').removeClass('hide');
2816									if (v.title || v.caption) {					
2817										var gallery_caption = v.caption;
2818										gallery_caption = gallery_caption.replace(/\n/g,'<br />');
2819
2820										ftitle.html(v.title);
2821										fcaption.html(gallery_caption);
2822										if(fdatetime.length > 0) fdatetime.text(v.datetime);
2823										if(fhashtag.length > 0) fhashtag.text(v.hashtag);
2824									}
2825
2826			                        if(g_number) {
2827			                            var g_index = String(index + 1),
2828			                                g_num = g_index.padStart(g_number, '0');
2829			                            $(c).find('.figure.number').text(g_num);
2830			                        }
2831
2832									if(fbrand.length > 0) {
2833										var fbrand_name = (typeof v.brand_name != 'undefined' && v.brand_name) ? v.brand_name : '';
2834										fbrand.html(v.brand_name);
2835									}
2836
2837									if(val.mode == 'shopping' || val.seq == 'all_products') {
2838										fcomment.addClass('hide');
2839										flike.addClass('hide');
2840										v.price = typeof v.price != 'undefined' ? parseFloat(v.price) : 0;
2841										v.sale = typeof v.sale != 'undefined' ? parseFloat(v.sale) : 0;
2842										var productGradeOnOff = getShoppingGradeProductGradeOnOff(v);
2843										$(c).attr('data-editor-grade-price-enabled', productGradeOnOff).attr('data-config-grade-price-enabled', productGradeOnOff);
2844										var checkPriceHidden = isShoppingGradePriceHidden(v),
2845											base_gallery_price = (v.price && !checkPriceHidden) ? v.price : 0,
2846											base_gallery_sale_price = (typeof v.sale != 'undefined' && v.sale > 0 && v.sale > v.price && !checkPriceHidden) ? v.sale : 0,
2847											gallery_price = base_gallery_price,
2848											gallery_sale_price = base_gallery_sale_price,
2849											gallery_sale_per = (typeof v.sale_per != 'undefined' && v.sale_per && !checkPriceHidden) ? v.sale_per+'%' : '',
2850											grade_price_display = settings.grade_price_display == 'ON',
2851											grade_discount_grade = getShoppingGradePreviewDiscountGrade(data.grade),
2852											grade_discount_applied = false,
2853											grade_gallery_price = 0,
2854											product_soldout = '품절',
2855											product_no_sale = (typeof settings.sh_soldout == 'string') ? settings.sh_soldout : '구매불가',
2856											product_status = '';
2857										if (
2858											!checkPriceHidden &&
2859											isShoppingGradeProductGradePriceEnabled(v)
2860										) {
2861											grade_gallery_price = calcShoppingGradeDisplayPrice(base_gallery_price, grade_discount_grade);
2862											grade_discount_applied = grade_gallery_price !== null;
2863										}
2864										if(v.status == 'off' && !checkPriceHidden) {
2865											product_status = '<span class="cl-sh-soldout">' + product_no_sale + '</span>';
2866										} else if(v.quantity_on == 'on' && v.quantity < 1 && !checkPriceHidden) {
2867											product_status = '<span class="cl-sh-soldout">' + product_soldout + '</span>';
2868										}
2869
2870										$(c).find('.cl-sh-soldout').remove();
2871										if(product_status != '') $(c).attr('data-soldout',true);
2872										else $(c).removeAttr('data-soldout');
2873
2874										$(c).find('.product-badge').remove();
2875										product_status += drawBadgeList(v.use_badge, data.badge_settings);
2876
2877										$(c).find('.cl-sh-limit').remove();
2878										if(v.status == 'lim') {
2879		                                    if(v.sale_now == false) {
2880		                                        var product_limit = '<p class="cl-sh-limit">상품 구매 가능 기간이 아닙니다.</p>';
2881					                            if(freview.length > 0) {
2882					                                freview.after(product_limit);
2883					                            } else {
2884					                                $(c).find('figcaption:not(.top) .figure:last-child').after(product_limit);
2885					                            }
2886		                                    }
2887		                                }
2888
2889										if($(c).find('ul.figure.price').length > 0) {
2890											// var price_off = (v.sale_price > 0 && v.sale_price > v.price) ? 100 - Math.floor((v.price / v.sale_price) * 100) : 0,
2891											// 	off_str = (price_off > 0) ? price_off + '% ' : ''
2892											var off_str = (v.sale_rate > 0) ? v.sale_rate + '% ' : '';
2893											if(!_this.b.LUX) off_str = gallery_sale_per;
2894											if(!off_str && gallery_sale_price > 0 && gallery_price > 0 && gallery_price < gallery_sale_price) {
2895												var price_off = Math.round(((gallery_sale_price - gallery_price) / gallery_sale_price) * 100);
2896												off_str = (price_off > 0) ? price_off + '% ' : '';
2897											}
2898											//Ver2
2899											if(!checkPriceHidden) {
2900												var $priceWrap = $(c).find('ul.figure.price'),
2901													$priceVal = $priceWrap.find('.price-val'),
2902													$priceSale = $priceWrap.find('.price-sale'),
2903													$priceSalePer = $priceWrap.find('.price-sale-per');
2904												$priceWrap.find('.sp-price, .grade-discount-price').remove();
2905												if($priceSale.length > 0 && $priceSalePer.length == 0) {
2906													$priceSale.after('<li class="price-sale-per hide"></li>');
2907													$priceSalePer = $priceWrap.find('.price-sale-per');
2908												}
2909												$priceWrap.css({display:'', flexDirection:'', alignItems:''});
2910												$priceVal.css({order:'', display:''});
2911												$priceSale.css({order:'', display:'', marginRight:''});
2912												$priceSalePer.css({order:'', display:'', marginLeft:'', marginTop:''});
2913													$priceVal.html('₩' + gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,','));
2914												$priceVal.removeClass('hide');
2915
2916												if(gallery_sale_price > 0 && gallery_price < gallery_sale_price) {
2917													$priceSale.html('₩' + gallery_sale_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,','));
2918														$priceSalePer.html(off_str);
2919													$priceSale.removeClass('hide');
2920														$priceSalePer.removeClass('hide');
2921													if(!grade_discount_applied && _this.b.LUX && (v.hashtag).indexOf('특가세일') > -1 && $(c).find('ul.figure.price .sp-price').length == 0) {
2922														$(c).find('ul.figure.price .price-sale').after('<li class="sp-price">특가세일</li>');
2923													}
2924												} else {
2925													$priceSale.addClass('hide').html('');
2926													$priceSalePer.addClass('hide').html('');
2927
2928												}
2929												
2930												if(grade_price_display && grade_discount_applied) {
2931													$priceWrap.append('<li class="grade-discount-price"><span class="grade-discount-price-value">₩' + grade_gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,',') + '</span><span class="grade-discount-price-label">나의 할인가</span></li>');
2932												}
2933
2934												$(c).find('ul.figure.price .price-unit-pricing').remove();
2935												if(v.product_unit_str) {
2936													$(c).find('ul.figure.price').append(`<li class="price-unit-pricing">${v.product_unit_str}</li>`); // 단위당 가격
2937												}
2938											} else {
2939												$(c).find('ul.figure.price .price-val').html('₩0');
2940												$(c).find('ul.figure.price .price-val').addClass('hide');
2941											}
2942											if(val.seq == 'all_products' && checkPriceHidden) $(c).find('ul.figure.price').html('');
2943											if(product_status) $(c).find('ul.figure.price').append('<li>'+product_status+'</li>');
2944
2945											var badge_size = getBadgeSize(data.badge_settings);
2946											$(c).find('.cl-sh-soldout').removeClass('badge-small badge-medium badge-large');
2947											$(c).find('.cl-sh-limit').removeClass('badge-small badge-medium badge-large');
2948											if(badge_size) {
2949												$(c).find('.cl-sh-soldout').addClass(badge_size);
2950												$(c).find('.cl-sh-limit').addClass(badge_size);
2951											}
2952										} else {
2953											//Ver1
2954											if(fprice.length == 0) fprice = fcaption;
2955											
2956											if(checkPriceHidden) fprice.html('');
2957											else fprice.html('<span class="figure-krw">₩</span>' + gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,',') + product_status);
2958										}
2959
2960										if($(c).find('ul.figure.review').length > 0) {
2961											var gallery_review = (v.review_onoff && v.review_cnt) ? v.review_cnt : 0;
2962											if(gallery_review > 0) {
2963												$(c).find('ul.figure.review, ul.figure.review li').removeClass('hide');
2964												$(c).find('ul.figure.review .figure-review-cnt').html(gallery_review);
2965												$(c).find('ul.figure.review .figure-review-score').html(v.review_score);
2966											} else {
2967												$(c).find('ul.figure.review, ul.figure.review li').addClass('hide');
2968												$(c).find('ul.figure.review .figure-review-cnt, ul.figure.review .figure-review-score').html('');
2969											}
2970										}
2971
2972										if(fbasket.length > 0) {
2973											var checkOldBlock = ($(c).find('.figure.basket[data-oldver="true"]').length > 0) ? true : false,
2974												checkOldverBasket = (typeof settings.field_oldver != 'undefined' && settings.field_oldver && settings.field_oldver.indexOf('basket') > -1) ? true : false,
2975												checkDisabledBasket = (typeof settings.field_disable != 'undefined' && settings.field_disable && settings.field_disable.indexOf('basket') > -1) ? true : false;
2976											if(v.basket_off || v.shopping_grade_hidden == 'ON') fbasket.addClass('cannotby hide');
2977											else if(val.seq == 'all_products') fbasket.removeClass('hide');
2978											else if(checkDisabledBasket || (!checkDisabledBasket && checkOldBlock && !checkOldverBasket)) fbasket.addClass('hide');
2979											else if(property.VALIDTYPE != 'SM') fbasket.addClass('hide');
2980											else fbasket.removeClass('hide');
2981										}
2982
2983									} else {
2984										fbrand.addClass('hide');
2985										fprice.addClass('hide');
2986										freview.addClass('hide');
2987										fbasket.addClass('hide');
2988
2989										if ( checkUseComment 
2990											&& settings.comment_display == 'ON'
2991											&& !(settings.field_disable !== undefined && settings.field_disable.indexOf('comment') > -1)
2992											&& fcomment.length > 0
2993											&& (typeof v.comment_cnt != 'undefined' && v.comment_cnt > 0)
2994										) {
2995											fcomment.removeClass('hide');
2996											fcomment.find('.figure-comment-cnt').html(v.comment_cnt);
2997										} else {
2998											fcomment.addClass('hide');
2999											fcomment.find('.figure-comment-cnt').empty();
3000										}
3001			
3002										if ( checkUseLike 
3003											&& (settings.like_display !== undefined && settings.like_display != 'N')
3004											&& !(settings.field_disable !== undefined && settings.field_disable.indexOf('like') > -1)
3005											&& flike.length > 0
3006										) {
3007											flike.removeClass('hide').find('.figure-like-cnt').html(0);
3008											if(v.like !== undefined) {
3009												flike.find('.figure-like-cnt').html(v.like.cnt);
3010												if (v.like.own && v.like.cnt > 0) flike.attr('data-like', v.seq).addClass('active');
3011											}
3012										} else {
3013											flike.addClass('hide');
3014										}
3015									}
3016									
3017									if(val.mode == 'gallery') {
3018										if(index < cookie_view) {
3019											$(p).find('[data-loop="true"]').append($(c)[0].outerHTML);
3020										} else {
3021											$(c).find('figure').remove();
3022											$(g).find('[data-loop="true"]').append($(c)[0].outerHTML);
3023										}
3024										if (total == 2) {
3025											$(c).find('figure').remove();
3026											$('.gallery-empty').append($(c)[0].outerHTML);
3027										}
3028									} else {
3029										$(p).find('[data-loop="true"]').append($(c)[0].outerHTML);
3030									}
3031
3032								});
3033								
3034							} else {
3035								checkGalleryListSample = true;
3036								if(val.mode=='project' && b.TEMPLATE == false) {
3037									nodes.addClass('gallery-item');
3038									nodes.find('a').attr('href', ((URI=='/') ? '' : URI) + '/' + elementPage + '/view/template').removeAttr('data-gallery').find('img').attr('data-index',0);
3039								}
3040
3041								if(b.TEMPLATE !== false) {
3042									if ( checkUseComment 
3043										&& settings.comment_display == 'ON'
3044										&& !(settings.field_disable !== undefined && settings.field_disable.indexOf('comment') > -1)
3045									) {
3046										nodes.find('.figure.comment').removeClass('hide');
3047									} else {
3048										nodes.find('.figure.comment').addClass('hide');
3049									}
3050		
3051									if ( checkUseLike 
3052										&& (settings.like_display !== undefined && settings.like_display != 'N')
3053										&& !(settings.field_disable !== undefined && settings.field_disable.indexOf('like') > -1)
3054									) {
3055										nodes.find('.figure.like').removeClass('hide');
3056									} else {
3057										nodes.find('.figure.like').addClass('hide');
3058									}
3059								}
3060
3061								$(p).find('[data-loop="true"]').append(nodes);
3062							}
3063							if(checkLoadmoreInLoop) $(p).find('[data-loop="true"]').append(glm);
3064
3065							tag = $(p)[0].outerHTML;
3066
3067							if (val.mode == 'gallery' && total == 2) {
3068								$.each($('.gallery-empty').find('.gallery-item'), function(i,v) {
3069									$(g).find('[data-loop="true"]').append(v);
3070								});
3071							}
3072							$('#el-empty').empty();
3073							$('.gallery-empty').remove();
3074						}
3075					});
3076				} else {
3077					if(typeof pageID[1] != 'undefined' && idx==0 && pageID[1] != 'template' && b.COUNT==0) {
3078						d = document.createElement('div');
3079						$(d).addClass('temp-element').html(tag);
3080						var pTitle = (b.PARENT.title) ? b.PARENT.title : $.lang[block_lang]['editor.block.gallery.sample.title'];
3081							pCaption = (b.PARENT.caption) ? b.PARENT.caption : $.lang[block_lang]['editor.block.gallery.sample.caption'];
3082						pCaption = pCaption.replace(/\n/g, '<br />');
3083
3084						$(d).find('.data-date').text(b.PARENT.datetime);
3085						$(d).find('.data-category').text(b.PARENT.category);
3086						$(d).find('h5.figure').text(pTitle);
3087						$(d).find('p.figure').not('.comment').html(pCaption);
3088
3089						tag = $(d).html();
3090						$(d).remove();
3091						tmpTag = tag;
3092					}
3093				}
3094
3095				//add style
3096				var $style_tag = $('<style type="text/css"></style>');
3097				$style_tag.attr('id','el_'+idx+'css');
3098				if(typeof val.elcss != 'undefined') {
3099					$style_tag.html(htmlspecialchars_decode(val.elcss));
3100					$('.header').before($style_tag);
3101				}
3102
3103				//change carousel id
3104				var $tag = $(tag);
3105				if(tabmenuSectionPage) $tag.attr('data-tabmenu-page', tabmenuSectionPage);
3106				if(val.type == 'tabmenu'
3107					&& window.clTabmenu
3108					&& typeof window.clTabmenu.reusePreservedPageBlock == 'function'
3109					&& window.clTabmenu.reusePreservedPageBlock($tag[0], currentPAGE)
3110				) {
3111					return Promise.resolve();
3112				}
3113				$tag.find('video').attr({'playsinline': '','webkit-playsinline': ''});
3114				$.each($tag.find('[data-edit="true"]'), function(i,v) {
3115					var source = $(this).outerHTML();
3116					source = source.replace(/&lt;&nbsp;/g,'&lt;').replace(/&nbsp;&gt;/g,'&gt;').replace(/data-attr-bookmark/g,'attr-bookmark');
3117					$(this).replaceWith(source);
3118				});
3119				
3120				if(typeof total == 'undefined') total = 0;
3121
3122				msny = (val.feature=='masonry') ? true : false;
3123				var blocklang = '';
3124
3125				if(val.type == 'video') {
3126					if($tag.find('.video-gallery-url').length > 0) val.mode = 'zoom';
3127					else val.mode = 'thumb';
3128					resizeVideoIframe($tag);
3129				}
3130
3131	            if (val.type == 'video' || val.type == 'others') {
3132	                var checkFullscreen = (typeof settings.fullscreen != 'undefined' && settings.fullscreen == 'ON') ? true : false;
3133	                if(checkFullscreen) {
3134	                    $tag.find('.video-wrap').addClass('video-fullscreen');
3135	                }
3136	            }
3137
3138				slideEffectClassAdd($tag);
3139
3140				let $last_el = ($('.fnav').length) ? $('.fnav') : $('.el-footer');
3141				$last_el.before(`<template class="elementAddPoint" data-id="${val.seq}"></template>`);
3142
3143				//페이지 이동
3144				$tag.addClass('el_' + idx)
3145					.attr('data-id', val.seq)
3146					.attr('data-el','el_' + idx)
3147					.attr('data-pos', idx+1)
3148					.attr('data-name', val.elname)
3149					.attr('data-msny', msny)
3150					.attr('data-type', val.type)
3151					.attr('data-type2', val.type2)
3152					.attr('data-feature', val.feature)
3153					.attr('data-mode', val.mode)
3154					.attr('data-width', val.folder)
3155					.attr('data-overlap',val.overlap)
3156					.attr('data-case', settings?.blockorg || val.name);
3157				if(val.type == 'form' && typeof val.form_done != 'undefined') $tag.attr('data-form-done', val.form_done);
3158
3159				setBlockAOS($tag,{block:settings, skipRefresh:true});
3160
3161				if($tag.hasClass('modoo')) {
3162					if(window.innerWidth <= 768 && $tag.find('._spotHomesite').hasClass('is_bottom')) {
3163						$tag.find('._spotHomesite').removeClass('is_bottom');
3164					}
3165
3166					if($tag.find('._sectionSpot').hasClass('type_full') && window.innerWidth > 768) {
3167						var A = $tag.find('._areaLogin').length ? true : false,
3168							C = window.innerHeight;
3169	
3170						if (A) {
3171							C -= 50;
3172						}
3173						
3174						$tag.find("._sectionSpot .swiper-wrapper").css("height", C);
3175						$tag.find("._sectionSpot .swiper-slide").css("height", C);
3176						$tag.find("._sectionSpot ._imgCover").css("height", C).each(function(F, G) {
3177							var D = $(G);
3178							var E = D.attr("data-lazy-background-img-src");
3179							D.css({
3180								backgroundImage: "url(" + E + ")",
3181								filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + E + '}", sizingMethod="scale")'
3182							});
3183						});
3184						if (!$tag.find("._spotHomesite").hasClass("is_bottom")) {
3185							$tag.find("._spotHomesite").css("height", C);
3186						}
3187					}
3188
3189					if($tag.find('.page-container-mobile').length > 0) {
3190						if(window.innerWidth <= 768) $tag.find('[data-role="page-container"]._content').hide();
3191						else $tag.find('[data-role="page-container"]._content').show();
3192					} 
3193
3194					if($tag.parents('body').is('.clnav-overlap-OFF') && $tag.is('[data-el="el_0"]')) {
3195						$tag.find('._spotHomesite .site_info').append(fl_data.el_html);
3196					}
3197				}
3198				
3199				var checkNotSupported = (!is_templates) ? $.notSupported.check(val.type,val.type2,val.feature) : false;
3200				if(checkNotSupported) {
3201					$tag.html('').attr('class',`hide element ${val.elname} el_${idx}`);
3202					$last_el = ($('.fnav').length) ? $('.fnav').before($tag) : $('.el-footer').before($tag);
3203					$(`#el_${idx}css, #js_${idx}`).remove();
3204					return Promise.resolve();
3205				}
3206
3207				if(typeof settings.blocklang != 'undefined') {
3208					blocklang = settings.blocklang;
3209					$tag.attr('data-blocklang',blocklang);
3210				}
3211
3212				if(val.type == 'contact') {
3213					setContactSubmitSecurity($tag, val.seq, settings, block_lang);
3214				}
3215
3216				if (val.type == 'sync') {
3217					showHideSyncField($tag, settings);
3218
3219					var sync_list_total = (typeof val.sync !='undefined' && typeof val.sync.list != 'undefined' && (val.sync.list).length > 0) ? (val.sync.list).length : 0;
3220					if($tag.find('.slick-page-label').length > 0) {
3221						var page_label = sync_list_total;
3222						if(val.type2 == 'imgpitem' && sync_list_total == 0) page_label = $tag.find('.slick .item').length;
3223
3224	                    $tag.find('.slick-page-label .slick-page-now').text(1);
3225	                    $tag.find('.slick-page-label .slick-page-total').text(page_label);
3226					}
3227
3228					if($tag.find('.sync-option').length > 0) {
3229						var sync_css = CSSJSON.toJSON(htmlspecialchars_decode(val.elcss)),
3230							sync_s = style.get(sync_css,val.elname);
3231						if(typeof sync_s.__display_count != 'undefined') {
3232							var display_cnt = Number(sync_s.__display_count) || 10;
3233							$tag.find(`.sync-item:gt(${display_cnt-1}
3233)`).addClass('hide');
3234
3235							if($tag.find('.sync-page-label').length > 0) {
3236								var sync_p_cnt = $tag.find('.sync-row .sync-item').length,
3237									sync_p_total = Math.ceil(sync_p_cnt / display_cnt);
3238								$tag.find('.sync-page .sync-page-now').text(1);
3239								$tag.find('.sync-page .sync-page-total').text(sync_p_total);
3240									
3241								if(sync_p_total == 1) $tag.find('.sync-page-wrap').hide();
3242								else $tag.find('.sync-page-wrap').show();
3243							}
3244						}
3245					}
3246
3247					var sync_loadmore_lang = block_lang;
3248					if(typeof settings.loadmore_lang != 'undefined' && settings.loadmore_lang && $.inArray(settings.loadmore_lang.toLowerCase(), ['ko','en']) > -1) sync_loadmore_lang = settings.loadmore_lang.toLowerCase();
3249					$tag.find('.sync-page-more-str').text($.lang[sync_loadmore_lang]['config.loadmore']);
3250				}
3251								
3252				if(checkGalleryView) {
3253					if(val.page == 'fixedblock_'+b.PARENT.pid) $tag.addClass('el-fixedblock');
3254					else $tag.removeClass('el-fixedblock');
3255
3256					$tag.attr('data-pos', page_pos);
3257					// if(b.LUX && (val.orgpos == '1' || $tag.is('.lux-product-block'))) $tag.attr('data-ppos', (val.pos*1) + 1);
3258					// else $tag.attr('data-ppos', val.pos);
3259					$tag.attr('data-ppos', val.pos);
3260					$tag.attr('data-posby', val.elnew);
3261				}
3262
3263				if(val.type == 'contact' && val.page == 'fixedcontact') {
3264					$.fixedContact.init($tag);
3265	            }
3266
3267				if(val.type=='forum' || val.type=='latest') $tag.addClass('preloading');
3268
3269				var tabmenuSectionStart = val.tabmenu_section_start || '';
3270				var checkPageblock = (val.seq === 'all_products' || (val.orgpos == 1 && val.orgpage)) ? true : false;
3271				if(tabmenuSectionStart) {
3272					$tag.attr('data-pagename', tabmenuSectionStart);
3273					$tag.addClass('link-to-'+JSON.parse('"'+tabmenuSectionStart.replace(/ /g,'-')+'"'));
3274				}
3275				if(b.ONE && checkPageblock) {
3276					$tag.attr('data-pagename', val.orgpage);
3277					$tag.addClass('link-to-'+JSON.parse('"'+val.orgpage.replace(/ /g,'-')+'"'));
3278				}
3279
3280				$tag.addClass('element');
3281				$last_el = ($('.fnav').length) ? $('.fnav') : $('.el-footer');
3282
3283				if($tag.hasClass('error_404')==false) {
3284					if($tag.hasClass('el-footer')==false) {
3285						if($tag.hasClass('cl-s-product-detail')==false) {
3286							if(typeof setBlockAOS == 'function') setBlockAOS($tag,{block:settings, skipRefresh:true});
3287							else aosAddblock(site_settings,settings,$tag);
3288						}
3289					}
3290				}
3291
3292				var data_aos_attr = '';
3293				if($tag.is('[data-aos]')) {
3294					data_aos_attr = $tag.attr('data-aos');
3295					$tag.removeAttr('data-aos');
3296					$tag.attr('data-aos-dummy', data_aos_attr);
3297					$tag.removeClass('aos-animate').addClass('aos-init')
3298				}
3299
3300				$last_el.before($tag);
3301				setOldVerBlockView($tag,val);
3302
3303				if(val.type == 'tabmenu' && window.clTabmenu && typeof window.clTabmenu.refresh == 'function') {
3304					window.clTabmenu.refresh($tag[0]);
3305				}
3306
3307				if(val.type == 'calendar'){
3308					var currentDate = new Date(),
3309						getYear = currentDate.getFullYear(),
3310						getMonth = String(currentDate.getMonth() + 1).padStart(2, "0"),
3311						yearMonth = getYear + '-' + getMonth;
3312					$.cl_calendar.init(val.sid, val.seq, yearMonth, val);
3313				}
3314
3315				if(val.type == 'sns' && typeof val.type2 != 'undefined' && val.type2 == 'feed') {
3316					$tag.find('.data-feed-load-more').attr('data-feed-el',val.elname);
3317					$tag.find('.data-feed-load-more').removeAttr('style');
3318					$tag.find('.show-posts').removeClass('show-posts');
3319
3320					if(val.mode == 'site') {
3321						if(!$.isEmptyObject(b.SOCIAL)) {
3322							var load_sns = {};
3323							if(!$.isEmptyObject(b.SOCIAL.instagram) && typeof settings.sns_instagram != 'undefined' && settings.sns_instagram == 'ON') load_sns['instagram'] = b.SOCIAL.instagram;
3324							if(!$.isEmptyObject(b.SOCIAL.twitter) && typeof settings.sns_twitter != 'undefined' && settings.sns_twitter == 'ON') load_sns['twitter'] = b.SOCIAL.twitter;
3325							
3326							if(!$.isEmptyObject(load_sns)) {
3327								loadingElement(val.elname,'loading posts...');
3328								updateFeed(val.elname, load_sns, settings, function() {
3329									$('.'+val.elname+' .listprogress').remove();
3330								});
3331							}
3332						}
3333					} else {
3334						// SNS FEED:: before version
3335						if(typeof settings.sns != 'undefined' &&  settings.sns.twitter) {
3336							loadingElement(val.elname,'loading posts...');
3337							updateFeed(val.elname,settings.sns);
3338						}
3339					}
3340				}
3341
3342				if(val.type == 'others' && typeof val.type2 != 'undefined' && val.type2 == 'countdown') {
3343					var el_dday = $tag.find('[data-dday="true"]'),
3344						cd_date = (el_dday.attr('data-countdown')) ? el_dday.attr('data-countdown') : new Date(),
3345						dateformat  = { days : '%D', hours: '%H', minutes: '%M', seconds: '%S' },
3346						dateendformat  = { days : '00', hours: '00', minutes: '00', seconds: '00' };
3347					
3348					if( typeof settings.countdown != 'undefined' && settings.countdown ) {  //set - block setting date 
3349						cd_date = settings.countdown;
3350					}
3351					if( !el_dday.attr('data-countdown') && typeof countdown == 'object' ) { //set - example date
3352						cd_date.setTime(cd_date.getTime() + (35*24*60*60*1000));
3353					}
3354					cd_date = moment(cd_date).format('YYYY/MM/DD HH:mm:ss');
3355
3356					el_dday.countdown(cd_date, function(event) {
3357						$(this).find('.date-item[data-datetype]').each(function(i) {
3358							var dd_type = $(this).attr('data-datetype'),
3359								dd_format = $(this).attr('data-format'),
3360								dd_endformat = $(this).attr('data-finish');
3361
3362							if(typeof dd_format == 'undefined' || !dd_format) dd_format = dateformat[dd_type];
3363							if(typeof dd_endformat == 'undefined' || !dd_endformat) dd_endformat = dateendformat[dd_type];
3364
3365							if(event.elapsed) $(this).text(dd_endformat);
3366							else $(this).text(event.strftime(dd_format));
3367						});
3368					});
3369
3370                	if($tag.find('[data-bg-video="true"]').length > 0) resizeVideoIframe($tag);
3371				}
3372
3373				if(typeof settings.bookmark != 'undefined' && settings.bookmark) {
3374					$tag.attr('data-bookmark',val.seq);
3375				}
3376
3377				if(val.type == 'gallery') {
3378					// gallery frame add
3379					if(val.mode == 'gallery' && total) tag = appendGalleryFrame($(tag), val.seq, val.type, val.elsettings);
3380					
3381					(checkGalleryListEmpty) ? $tag.addClass('emptyGallery') : $tag.removeClass('emptyGallery');
3382
3383					$tag.attr('data-category',category_onoff);
3384					$tag.attr('data-gallery-sort',gallery_sort);
3385
3386					if(category_onoff == 'ON'|| gallery_sort == 'product') {
3387						initGToolbar($tag, {id:val.seq, settings:settings});
3388					}
3389
3390					var img_onoff = (typeof settings.img_original_display != 'undefined' && settings.img_original_display) ? settings.img_original_display : 'ON',
3391						title_onoff = (typeof settings.gframe_title_visible != 'undefined' && settings.gframe_title_visible == 'OFF') ? 'OFF' : 'ON';
3392        				like = (typeof settings.like_display != 'undefined' && settings.like_display) ? settings.like_display : 'N';
3393
3394					$tag.find('[data-gallery]').attr({'data-img-original':img_onoff, 'data-gallery-title':title_onoff, 'data-gallery-like':like});
3395					if(!title_onoff) $tag.find('[data-gallery]').attr('data-title','');
3396
3397					if(isShoppingGradePriceHidden(val)) {
3398						$tag.find('.figure.price').html('');
3399					}
3400
3401					showHideGalleryField($tag,settings);
3402					reloadBlockMasonry('init', $tag);
3403
3404					var $glmBtnWrap = $tag.find('.loadmore-wrap'),
3405						$glmBtn = $tag.find('.loadmore-wrap .gallery-loadmore'),
3406						checkLoadmore = (total > view && total > cookie_view && !checkGalleryListEmpty) ? true : false,
3407						glm_lang = LANG;
3408
3409					if(typeof settings.loadmore_lang != 'undefined' && settings.loadmore_lang && $.inArray(settings.loadmore_lang.toLowerCase(), ['ko','en']) > -1) glm_lang = settings.loadmore_lang.toLowerCase();
3410					else if(typeof block_lang != 'undefined' && $.inArray(block_lang, ['ko','en']) > -1) glm_lang = block_lang;
3411					var glm_txt = $.lang[glm_lang]['config.loadmore'];
3412
3413					if($glmBtnWrap.length == 0) {
3414						// gallery loadmore btn - default (ver1)
3415						if(checkLoadmore) {
3416							var glm_class = (val.feature=='masonry') ? 'gallery-loadmore masonry-layout' : 'gallery-loadmore',
3417								glm_btn = '<div class="' + glm_class + '" data-loadmore="true" data-selector=".gallery-loadmore" data-total="' + total + '" data-id="' + val.seq + '" data-page="' + (Number(cookie_page)+1) + '" data-view="' + view + '" data-folder="' + val.folder + '" data-mode="' + val.mode + '">' + glm_txt +' &nbsp;(<span class="display">' + cookie_view + '</span> / ' + number_format(total) + ')</div>';
3418
3419							if($tag.find('.gallery-loadmore[data-id="'+val.seq+'"]').length > 0) $('.gallery-loadmore[data-id="'+val.seq+'"]').replaceWith(glm_btn);
3420							else $tag.append(glm_btn);
3421						} else $tag.find('.gallery-loadmore').remove();
3422
3423					} else {
3424						// gallery loadmore btn - custom (ver2)
3425						if(checkLoadmore) {
3426							if(val.feature=='masonry') $glmBtn.addClass('masonry-layout');
3427							else $glmBtn.removeClass('masonry-layout');
3428							$glmBtn.attr('data-loadmore','true').attr('data-id',val.seq).attr('data-total',total).attr('data-page',Number(cookie_page)+1).attr('data-view',view).attr('data-folder',val.folder).attr('data-mode',val.mode);
3429							$glmBtn.find('.label').text(glm_txt);
3430							$glmBtn.find('.display .view').text(cookie_view);
3431							$glmBtn.find('.display .total').text(total);
3432							$glmBtnWrap.removeClass('hide').fadeIn();
3433						} else {
3434							$glmBtnWrap.fadeOut().addClass('hide');
3435							$glmBtn.removeAttr('data-loadmore').removeAttr('data-id').removeAttr('data-total').removeAttr('data-page').removeAttr('data-view').removeAttr('data-folder').removeAttr('data-mode').removeClass('masonry-layout');
3436							$glmBtn.find('.label').text(glm_txt);
3437							$glmBtn.find('.display .view').text('0');
3438							$glmBtn.find('.display .total').text('0');
3439						}
3440					}
3441
3442					//갤러리블럭 모바일 가로 갯수 설정 시 클래스추가
3443					var gal_css = CSSJSON.toJSON(htmlspecialchars_decode(val.elcss)),
3444						gal_s = style.get(gal_css,val.elname),
3445						gal_case = $tag.attr('data-case'),
3446						gal_id = $tag.attr('data-id'),
3447						gal_name = $tag.attr('data-name');
3448					if(gal_s.__layout_m_on == 1 && gal_case != 'gallery61') {
3449						$tag.addClass('el-col-m'+gal_s.__layout_col_mc);
3450					} else if(gal_s.__layout_m_on == 1 && gal_case == 'gallery61') {
3451						$tag.addClass('el-col-m'+gal_s.__swiper_view_mc);
3452						setTimeout(function() {
3453							elGalleryJS[gal_id].gjs_load(document.querySelector('.'+gal_name));
3454						});
3455					}
3456				}
3457
3458				if(val.type == 'sync') {
3459					var sync_source = _this.syncUpdate($tag, val);
3460					$tag.html(sync_source);
3461
3462					if($tag.find('[data-sync-loop="true"]').length > 0) {
3463						if(val.type2 == 'tab') $tag.find('[data-sync-loop="true"] > li[data-list-no="1"]').attr('data-list-no','');
3464						if(val.type2 == 'imgpitem' && sync_list_total > 0) $tag.find('[data-sync-loop="true"] > li:not([data-idx])').remove();
3465						$tag.find('[data-sync-loop="true"] > li').eq(0).addClass('active').siblings().removeClass('active');
3466					}
3467				}
3468
3469				// tab block 우선순위 check
3470				if(val.type == 'tabs') {
3471					var $tabs = $tag.find(".tab-box .tab:not(.hover)"),
3472						$initial_tab = ($tabs.filter('.checked').length > 0) ? $tabs.filter('.checked').first() : $tabs.filter('.active').first();
3473					if($initial_tab.length == 0) $initial_tab = $tabs.eq(0);
3474					if($tabs.filter('.checked').length > 0) {
3475						$tabs.removeClass('active');
3476						$initial_tab.addClass('active');
3477						$tag.find('.tab-editor').removeClass('active');
3478						$tag.find('.tab-editor.tabs' + $initial_tab.attr('data-order')).addClass('active');
3479					}
3480					var el = $tag.attr('data-name'),
3481						len = $tabs.length,
3482						motion_style = $tag.attr("tab-motion-style"),
3483						tab_counted = $tag.attr("tab-count"),
3484						mobile_tab_count = $tag.attr("mobile-tab-count"),
3485						tab_count = ($(window).width() < 991) ? ((typeof mobile_tab_count != 'undefined' && mobile_tab_count) ? mobile_tab_count : ((tab_counted > 4) ? 4 : tab_counted)) : tab_counted,
3486						mobile_tab_line = $tag.attr("mobile-tab-line"),
3487						tab_case = $tag.attr("data-case"),
3488						motion = $tag.attr("tab-motion"),
3489						priority = Number($initial_tab.attr('data-order')) || 1,
3490						navigation_use = $tag.attr("navigation-use");
3491					tabArrow(el);
3492					if(navigation_use == '1' || ($(window).width() < 991 && mobile_tab_line == '1' && len > Number(tab_count))) {
3493						if(motion_style == 1) {
3494							var motion = (((priority + 1) - Number(tab_count)) >= 0) ? priority - Number(tab_count) : 0;
3495						} else {
3496							var motion = Math.ceil(Number(priority) / Number(tab_count)) - 1;
3497						}
3498						$tag.attr('tab-motion', motion);
3499						tabMotion(el, motion, "", len, motion_style, tab_count, tab_case);
3500					}
3501				}
3502
3503				if(val.seq == 'all_products') {
3504	                if (b.ONE) $tag.addClass('link-to-전체상품');
3505					setGToolbarAllProducts($tag, settings, val.total.list_total);
3506				}
3507
3508				if($tag.has('input.gjs').length) {
3509					var gjs_status = (typeof elGalleryJS[val.seq] != 'undefined') ? 'reload-block' : 'load-block';
3510					setGalleryJS(gjs_status,$tag);
3511				}
3512				
3513	            if(val.type == 'forum') {
3514	            	var view = $tag.find('[data-loop="true"]').attr('data-view');
3515	                if(typeof view == 'undefined') view = 10;
3516	                if(typeof $.cookie('forum_' + val.seq) != 'undefined' && $.cookie('forum_' + val.seq)) {
3517	                	$.forum.init(val.seq,b.PAGE,view,$.cookie('forum_' + val.seq),$.cookie('forum_'+ val.seq +'_sfl'),$.cookie('forum_'+ val.seq +'_stx'),$.cookie('forum_'+ val.seq +'_scate'));	          
3518	                } else {
3519	                	$.forum.init(val.seq,b.PAGE,view);
3520					}
3521	                	
3522	                $.removeCookie('forum', { path : '/' });
3523	                $.removeCookie('forum_'+val.seq, { path : '/' });
3524	                $.removeCookie('forum_'+val.seq+'_sfl', { path : '/' });
3525	                $.removeCookie('forum_'+val.seq+'_stx', { path : '/' });
3526	                $.removeCookie('forum_'+val.seq+'_scate', { path : '/' });
3527
3528					if(val.type2 == 'guestbook') {						
3529	                    if(settings.input_updown == 'U') {                    	
3530	                        $tag.find('.default_top').removeClass('flex-value-order2').addClass('flex-value-order1');
3531	                        $tag.find('.default_bottom').removeClass('flex-value-order1').addClass('flex-value-order2');	                    
3532	                    } 
3533	                    else {
3534	                    	if (typeof settings.input_updown == 'undefined') {//블럭 추가 당시 세팅값 없을 때
3535                        	$tag.find('.default_top').removeClass('flex-value-order2').addClass('flex-value-order1');
3536                        	$tag.find('.default_bottom').removeClass('flex-value-order1').addClass('flex-value-order2');                            
3537                        	} else {
3538	                        $tag.find('.default_top').removeClass('flex-value-order1').addClass('flex-value-order2');
3539	                        $tag.find('.default_bottom').removeClass('flex-value-order2').addClass('flex-value-order1');
3540	                    	}
3541	                	}
3542	                }
3543				}
3544
3545				if(b.LUX && typeof res != 'undefined') {
3546					shopHeaderDisplay($tag.find('.shop-filter-header'),res);
3547				}
3548
3549				if(val.type == 'latest') {
3550					var latest_data = (typeof settings.latest_data != 'undefined' && settings.latest_data) ? settings.latest_data : {};
3551					$.latest.init(val.seq, latest_data);
3552					$tag.removeClass('preloading');
3553				}
3554
3555				if(val.type == 'review') {
3556					galleryEL[val.seq] = {
3557						'seq' : val.seq,
3558						'elname' : val.elname,
3559						'eltag' : tag,
3560						'folder' : val.folder,
3561						'mode' : val.mode,
3562						'elsettings' : val.elsettings,
3563						'feature' : val.feature,
3564						'type' : val.type,
3565						'type2' : val.type2,
3566						'searches' : val.searches
3567					};
3568					var gallery_data = (typeof settings.gallery_data != 'undefined' && settings.gallery_data) ? settings.gallery_data : {};
3569					$.reviewContents.init(val.seq, gallery_data);
3570				}
3571
3572				if(b.VIEW) {
3573					var img_onoff = (typeof settings.img_original_display != 'undefined' && settings.img_original_display) ? settings.img_original_display : 'OFF';
3574					$tag.find('img[data-attach="true"]').attr('data-img-original',img_onoff);
3575
3576					setGalleryReturnItemCookie(b.PARENT);
3577					var c_g_p = (typeof $.cookie('gallery-page-' + b.PARENT.pid) != 'undefined') ? $.cookie('gallery-page-' + b.PARENT.pid) : 1;
3578					$.cookie('gallery',b.PARENT.pid, { path: '/', expires: 12 * 60 * 60 * 1000 });
3579					$.cookie('loadmore-' + b.PARENT.pid, c_g_p, { path: '/', expires: 12 * 60 * 60 * 1000 });
3580					if(typeof $.cookie('gallery-page-all_products') !== 'undefined' && $.cookie('gallery-page-all_products')) {
3581						c_g_p = (typeof $.cookie('gallery-page-all_products') != 'undefined') ? $.cookie('gallery-page-all_products') : 1;
3582						$.cookie('gallery','all_products', { path: '/', expires: 12 * 60 * 60 * 1000 });
3583						$.cookie('loadmore-all_products', c_g_p, { path: '/', expires: 12 * 60 * 60 * 1000 });
3584					}
3585				}
3586
3587				$tag.find('[data-fixed-width]').each(function() {
3588					$(this).css('width',$(this).attr('data-fixed-width')+'px');
3589				});
3590
3591
3592				$tag.find('[data-map="true"]:not(iframe)').each(function() {
3593					var map_url = $(this).attr('data-url');
3594					if(typeof map_url != 'undefined' && map_url) {
3595						var map_iframe = getMapURL(map_url,'html');
3596						$(this).replaceWith(map_iframe);
3597						if(map_iframe.indexOf('google-map disabled') === -1) $(this).next('.map-undefined').remove();
3598					}
3599				});
3600
3601				if(val.type == 'contact' && val.type2 == 'franchise map') {
3602					$.each($tag.find('[data-fmap-loop="true"] .item .item-name'), function(i, v) {
3603                        let itemName = $(v).html();
3604                        itemName = itemName.replace(/&lt;&nbsp;/g, '&lt;').replace(/&nbsp;&gt;/g, '&gt;');
3605                        $(v).html(itemName);
3606                    });
3607
3608                    var $mapItem = $tag.find('[data-fmap-loop="true"] > .item.selected');
3609                    drawMap($mapItem, $tag);
3610                    fmapMobilePaging($tag);
3611                } else {
3612                	if($tag.find('[data-map_kind="kakao"]').length && (typeof kakao == 'undefined' || typeof kakao.maps == 'undefined' || 
3612kakao.maps == null || property.VALIDPLAN == '')) {
3613						$tag.find('[data-map_kind="kakao"]').html('지도연결해제됨. Javascript키 확인');
3614						$tag.find('[data-map_kind="kakao"]').html('<iframe class="google-map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3165.5659473821083!2d127.0282496015659!3d37.494568!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca1598c361b2b%3A0xdbf9af292beff3c!2z6rCV64Ko!5e0!3m2!1sko!2skr!4v1637303748377!5m2!1sko!2skr" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>');
3615					} else {
3616						$tag.find('[data-map_kind="kakao"]').each(function() {
3617							var container = this;
3618	                        var lat = $(this).data("lat");
3619	                        var lng = $(this).data("lng");
3620	                        var zoomInOut = $(this).data("zoominout");
3621	                        var mapTitle = $(this).data("maptitle");
3622	                        var mapContent = $(this).data("mapcontent");
3623	                        var useTitle = $(this).data("usetitle");
3624	                        var useContent = $(this).data("usecontent");
3625
3626	                        if (typeof zoomInOut == 'undefined' || !zoomInOut) zoomInOut = false;
3627	                        if (typeof mapTitle == 'undefined' || !mapTitle) mapTitle = '';
3628	                        if (typeof mapContent == 'undefined' || !mapContent) mapContent = '';
3629	                        if (typeof useTitle == 'undefined' || !useTitle) useTitle = false;
3630	                        if (typeof useContent == 'undefined' || !useContent) useContent = false;
3631	                        
3632	                        var options = { center: new kakao.maps.LatLng(lat, lng), level: 3 };
3633	                        var c_map = new kakao.maps.Map(container, options);
3634	                        var marker = new kakao.maps.Marker({ position: new kakao.maps.LatLng(lat, lng), map: c_map });
3635	                        
3636							if(zoomInOut == true) {
3637								// var mapTypeControl = new kakao.maps.MapTypeControl();
3638								// c_map.addControl(mapTypeControl, kakao.maps.ControlPosition.TOPRIGHT);
3639								// var zoomControl = new kakao.maps.ZoomControl();
3640								// c_map.addControl(zoomControl, kakao.maps.ControlPosition.RIGHT);
3641								var zoomControlHtml = '';
3642								zoomControlHtml += '\
3643									<div class="zoom-control" style="margin-top: 8px; margin-right: 8px; right: 0; width: 30px; position: absolute; background-color: #fff; z-index: 1; border-radius: 3px; box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);">\
3644										<div class="btn-zoom-control" data-inout="I" style="cursor: pointer; width: 30px; height: 30px;">\
3645											<svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 11h-4V7c0-.55-.45-1-1-1s-1 .45-1 1v4H7c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1v-4h4c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>\
3646										</div>\
3647										<div class="slider-wrap-container" style="height: 130px;">\
3648											<div class="slider-wrap small" style="text-align: center; height: 100%;">\
3649												<div style="max-height: 100%;" class="zoom-control-slider"></div>\
3650											</div>\
3651										</div>\
3652										<div class="btn-zoom-control" data-inout="O" style="cursor: pointer; width: 30px; height: 30px;">\
3653											<svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 13H7c-.55 0-1-.45-1-1s.45-1 1-1h10c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>\
3654										</div>\
3655									</div>\
3656								';
3657								var $zoomController = $(zoomControlHtml);
3658								$(container).append($zoomController);
3659								var zoom_slider = $zoomController.find('.zoom-control-slider').slider({
3660									'orientation': 'vertical',
3661									'min' : 1,
3662									'max' : 14,
3663									'step' : 1,
3664									'value' : 3,
3665									'handle' : '<div>dfafasdfas</div>',
3666									// 'reversed' : true,
3667									'tooltip' : 'hide',
3668								}).on('slide', function(data) {
3669									c_map.setLevel(data.value);
3670									c_map.setCenter(marker.getPosition());
3671								}).on('slideStop', function(data) {
3672									c_map.setLevel(data.value);
3673									c_map.setCenter(marker.getPosition());
3674								});
3675
3676								$zoomController.find('.btn-zoom-control').on('click', function() {
3677									if($(this).data('inout') == 'I') {
3678										c_map.setLevel(c_map.getLevel() - 1);
3679										zoom_slider.slider('setValue', c_map.getLevel());
3680									} else if($(this).data('inout' == 'O')) {
3681										c_map.setLevel(c_map.getLevel() + 1);
3682										zoom_slider.slider('setValue', c_map.getLevel());
3683									}
3684								});
3685
3686								kakao.maps.event.addListener(c_map, 'zoom_changed', function() {
3687									zoom_slider.slider('setValue', c_map.getLevel());
3688								});
3689							}
3690
3691							if((useTitle == true || useContent == true) && (mapTitle || mapContent)) {
3692								var iwContent = '';
3693								if(useTitle == true && mapTitle) {
3694									iwContent = '<div class="title">' + mapTitle + '</div>';
3695								}
3696								if(useContent == true && mapContent) {
3697									iwContent += '<div class="content">' + mapContent + '</div>';
3698								}
3699								// var infowindow = new kakao.maps.InfoWindow({
3700								//     position: marker.getPosition(),
3701								//     content : iwContent
3702								// });
3703								// infowindow.open(c_map, marker);
3704								if(iwContent) {
3705									iwContent = '<div class="contact-map-info-window"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 0C4.69 0 2 2.69 2 6s1 4 6 10c5-6 6-6.69 6-10s-2.69-6-6-6zm0 8.3a2.3 2.3 0 1 1 0-4.6 2.3 2.3 0 0 1 0 4.6z"></path></svg>
3705' + iwContent + '</div>';
3706									var infoWindow = $(iwContent);
3707									$(container).append(infoWindow);
3708									// infoWindow.css('bottom', 'calc(-100% + ' + (infoWindow.outerHeight() + 36) + 'px)');  
3709								}
3710							}
3711							$(window).on("resize", function() {
3712								c_map.setCenter(marker.getPosition());
3713							});
3714						});
3715					}
3716
3717					if($tag.find('[data-map_kind="naver"]').length && (typeof naver == 'undefined' || typeof naver.maps == 'undefined' || naver.maps == null || property.VALIDPLAN == '')) {
3718						$tag.find('[data-map_kind="naver"]').html('지도연결해제됨. Client ID 확인');
3719						$tag.find('[data-map_kind="naver"]').html('<iframe class="google-map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3165.5659473821083!2d127.0282496015659!3d37.494568!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca1598c361b2b%3A0xdbf9af292beff3c!2z6rCV64Ko!5e0!3m2!1sko!2skr!4v1637303748377!5m2!1sko!2skr" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>');
3720					} else {
3721						$tag.find('[data-map_kind="naver"]').each(function() {
3722							var container = this;
3723							var lat = $(this).data("lat");
3724							var lng = $(this).data("lng");
3725							var options = { center: new naver.maps.LatLng(lat, lng), zoom: 17};
3726							var c_map = new naver.maps.Map(container, options);
3727							var marker = new naver.maps.Marker({ position: new naver.maps.LatLng(lat, lng), map: c_map});
3728							var zoomInOut = $(this).data("zoominout");
3729							var mapTitle = $(this).data("maptitle");
3730							var mapContent = $(this).data("mapcontent");
3731							var useTitle = $(this).data("usetitle");
3732							var useContent = $(this).data("usecontent");
3733							if(typeof zoomInOut == 'undefined' || !zoomInOut) zoomInOut = false;
3734							if(typeof mapTitle == 'undefined' || !mapTitle) mapTitle = '';
3735							if(typeof mapContent == 'undefined' || !mapContent) mapContent = '';
3736							if(typeof useTitle == 'undefined' || !useTitle) useTitle = false;
3737							if(typeof useContent == 'undefined' || !useContent) useContent = false;
3738							if(zoomInOut == true) {
3739								// options.zoomControl = true;
3740								var zoomControlHtml = '';
3741								zoomControlHtml += '\
3742									<div class="zoom-control" style="margin-top: 8px; margin-right: 8px; right: 0; width: 30px; position: absolute; background-color: #fff; z-index: 1; border-radius: 3px; box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);">\
3743										<div class="btn-zoom-control" data-inout="I" style="cursor: pointer; width: 30px; height: 30px;">\
3744											<svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 11h-4V7c0-.55-.45-1-1-1s-1 .45-1 1v4H7c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1v-4h4c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>\
3745										</div>\
3746										<div class="slider-wrap-container" style="height: 130px;">\
3747											<div class="slider-wrap small" style="text-align: center; height: 100%;">\
3748												<div style="max-height: 100%;" class="zoom-control-slider"></div>\
3749											</div>\
3750										</div>\
3751										<div class="btn-zoom-control" data-inout="O" style="cursor: pointer; width: 30px; height: 30px;">\
3752											<svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 13H7c-.55 0-1-.45-1-1s.45-1 1-1h10c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>\
3753										</div>\
3754									</div>\
3755								';
3756								var $zoomController = $(zoomControlHtml);
3757								$(container).append($zoomController);
3758								var zoom_slider = $zoomController.find('.zoom-control-slider').slider({
3759									'orientation': 'vertical',
3760									'min' : 6,
3761									'max' : 21,
3762									'step' : 1,
3763									'value' : 17,
3764									'handle' : '<div>dfafasdfas</div>',
3765									'reversed' : true,
3766									'tooltip' : 'hide',
3767								}).on('slide', function(data) {
3768									c_map.setZoom(data.value);
3769									c_map.setCenter(marker.getPosition());
3770								}).on('slideStop', function(data) {
3771									c_map.setZoom(data.value);
3772									c_map.setCenter(marker.getPosition());
3773								});
3774								$zoomController.find('.btn-zoom-control').on('click', function() {
3775									if($(this).data('inout') == 'I') {
3776										c_map.setZoom(c_map.getZoom() + 1);
3777										zoom_slider.slider('setValue', c_map.getZoom());
3778									} else if($(this).data('inout' == 'O')) {
3779										c_map.setZoom(c_map.getZoom() - 1);
3780										zoom_slider.slider('setValue', c_map.getZoom());
3781									}
3782								});
3783
3784								naver.maps.Event.addListener(c_map, 'zoom_changed', function(zoom) {
3785									zoom_slider.slider('setValue', c_map.getZoom());
3786								});
3787							}
3788
3789							if((useTitle == true || useContent == true) && (mapTitle || mapContent)) {
3790								var iwContent = '';
3791								if(useTitle == true && mapTitle) {
3792									iwContent = '<div class="title">' + mapTitle + '</div>';
3793								}
3794								if(useContent == true && mapContent) {
3795									iwContent += '<div class="content">' + mapContent + '</div>';
3796								}
3797
3798								if(iwContent) {
3799									iwContent = '<div class="contact-map-info-window"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 0C4.69 0 2 2.69 2 6s1 4 6 10c5-6 6-6.69 6-10s-2.69-6-6-6zm0 8.3a2.3 2.3 0 1 1 0-4.6 2.3 2.3 0 0 1 0 4.6z"></path></svg>
3799' + iwContent + '</div>';
3800									var infoWindow = $(iwContent);
3801									$(container).append(infoWindow);
3802									// infoWindow.css('bottom', 'calc(-100% + ' + (infoWindow.outerHeight() + 36) + 'px)');  
3803								}
3804								// var infowindow = new naver.maps.InfoWindow({
3805								//     content : iwContent
3806								// });
3807								// infowindow.open(c_map, marker);
3808							}
3809							$(window).on("resize", function() {
3810								c_map.setCenter(marker.getPosition());
3811							});
3812						});
3813					}
3814                }
3815
3816				if(val.type == 'form' || (val.type == 'contact' && val.type2 == 'franchise bar')) {
3817					$.forms.init(val.seq);
3818				}
3819
3820				if(val.type == 'showcase') {
3821					if($tag.hasClass('carousel') && $tag.find('.item').length > 1 && $tag.find('.control-box .carousel-control').hasClass('hide')) {
3822						$tag.find('.control-box .carousel-control').removeClass('hide');
3823					}
3824				}
3825
3826				//video block ::: gallery
3827				if(val.type == 'video') {
3828					if($tag.find('.video-gallery-url').length>0) { //재생방식 : 확대보기 
3829						$.each($tag.find('.item'),function(i,v){
3830							if(val.mode=='zoom') appendGalleryFrame($(this).parents('.element'),val.seq,val.type);
3831						});
3832
3833	                    // let lsw = document.querySelector('.element[data-id="' + val.seq + '"] .swiper');
3834		                // if(lsw && lsw.swiper) {
3835	                    //     let slider_motion = $('.element[data-id="' + val.seq + '"]').attr('data-slider-motion');
3836
3837		                // 	$('#gframe-' + val.seq).on('opened', function(event, slide){
3838				        //     	console.log('gallery opend', slider_motion);
3839	                    //         if(slider_motion != 'stop') {
3840	                    //             lsw.swiper.autoplay.stop();
3841	                    //         }
3842		                //     }).on('closed', function (event){
3843				        //     	console.log('gallery closed');
3844	                    //         if(slider_motion != 'stop') {
3845	                    //             lsw.swiper.autoplay.start();
3846		                //         }
3847		                //     });
3848						// }
3849					}
3850
3851					resizeVideoIframe($tag);
3852				}
3853
3854				//add script
3855				if(val.eljs){
3856					var js_string = val.eljs;
3857					var $script_tag = $('<script type="text/javascript" id="js_' + idx + '"></script>');
3858					$script_tag.html(js_string);
3859					$('.dsgn-body').append($script_tag);
3860				}
3861
3862				if($tag.find('.slick').length > 0) {
3863					if (val.type == 'sync' && typeof syncSlickFn == 'function') syncSlickFn('.' + val.elname);
3864					else if($tag.is('[data-clslick]') && typeof clSlickFn == 'function') clSlickFn('.' + val.elname);
3865				}
3866
3867				// log 
3868				if(typeof settings['google_track'] != 'undefined') {
3869					$('.dsgn-body').append("<script type='text/javascript' src='//www.googleadservices.com/pagead/conversion_async.js'></script>");
3870				}
3871
3872				//add style
3873				var jcss = CSSJSON.toJSON(val.elcss);
3874
3875				var element_mh = jcss?.children[`.${val.elname}`]?.attributes['min-height'] ?? '';
3876				if (element_mh && /%$/.test(element_mh)) {
3877					const converted_mh = element_mh.replace('%', '');
3878					$tag.css('min-height',`${converted_mh}vh`);
3879				}
3880
3881				var elpd = style.getPadding(jcss,val.elname);
3882				var pt = parseInt(elpd.top);
3883				var pb = parseInt(elpd.bottom);
3884					
3885				if(pt>0||pb>0){
3886					default_t_css = default_t_css + '\n 	.'+val.elname + '{';
3887					if(Math.ceil(pt*0.8)>0)
3888					default_t_css = default_t_css + 'padding-top: '+Math.ceil(pt*0.8) + 'px!important;';
3889					if(Math.ceil(pb*0.8)>0)
3890					default_t_css = default_t_css + 'padding-bottom: '+Math.ceil(pb*0.8) + 'px!important;';
3891					default_t_css = default_t_css + '}';
3892
3893					default_m_css = default_m_css + '\n 	.'+val.elname + '{';
3894					if(Math.ceil(pt*0.5)>0)
3895					default_m_css = default_m_css + 'padding-top: '+Math.ceil(pt*0.5) + 'px!important;';
3896					if(Math.ceil(pb*0.5)>0)
3897					default_m_css = default_m_css + 'padding-bottom: '+Math.ceil(pb*0.5) + 'px!important;';
3898					default_m_css = default_m_css + '}';
3899				}
3900				if(idx == data.length-1){
3901					var css = '@media only screen and (max-width:767px) {' + default_t_css + '\n}\n';
3902					css = css + '@media only screen and (max-width:480px) {' + default_m_css + '\n}';
3903
3904					if($('#el-paddingcss').length == 0) $('.dsgn-body').find('#el_'+(data.length-1)+'css').after('<style id="el-paddingcss">'+css+'</style>');
3905					else $('#el-paddingcss').append(css);
3906				}
3907				
3908				if(val.type == 'product') {
3909					if(val.is_wishlist == true) {
3910						$('.product-detail-btn .btn-myfav .btn-myfav-icon').addClass('on');
3911					} else {
3912						$('.product-detail-btn .btn-myfav .btn-myfav-icon').removeClass('on');
3913					}
3914				}
3915
3916				if($.inArray(val.type, ['contents', 'text', 'image', 'video']) > -1) {
3917					let ecs = enableContentsSlider(val.seq, val.type, settings);
3918					if(typeof settings.list_type != 'undefined' && settings.list_type == 's' && ecs) {
3919	                    $.contentsSlider.ready(val.seq).then(() => {$.contentsSlider.init(val.seq, settings)});
3920	                }
3921				}
3922
3923				return new Promise(function(resolve) { setTimeout(resolve) });
3924			}
3925
3926			if(check_modoo) {
3927				m_floating(fl_data);
3928			}
3929			var dataloop = async function(data) {
3930				var promises = data.map(async function(val, idx) {
3931					return await drawData(idx, val)
3932				});
3933				return await Promise.all(promises);
3934			}
3935
3936			if(checkGalleryView) setViewPageStyle();
3937			dataloop(data).then(function() {
3938				if(window.clTabmenu && typeof window.clTabmenu.refresh == 'function') window.clTabmenu.refresh(document);
3939				hidePageContentLoading();
3940				if(window.clTabmenu && typeof window.clTabmenu.finishPageChange == 'function') window.clTabmenu.finishPageChange();
3941				$('.el-footer').css('visibility', 'visible');
3942				$.processOFF();
3943
3944				document.querySelectorAll('.element video').forEach(function(video) {
3945					if(video.readyState > 0) video.classList.add('loaded');
3946					video.addEventListener('loadeddata', function() {
3947						this.classList.add('loaded');
3948					});
3949				});
3950
3951				$('.dsgn-body').fitVids();
3952				if(window.clTextCount && window.clTextCount.init) {
3953					window.clTextCount.init($('.dsgn-body').get(0) || document, true);
3954				}
3955
3956				$('.carousel').carousel({
3957					pause: 'none'
3958				});
3959				
3960				if(!pageMoveAOSPending) {
3961					restorePageMoveAOS();
3962					setTimeout(function() {
3963						$('.element[data-aos]').removeClass('render-aos').addClass('aos-animate');
3964						AOS.init({ disableMutationObserver: true });
3965					});
3966				}
3967				changeBrokenImages('.element');
3968				
3969				$('.element').each(function(i,v){
3970					var $tag = $(v);
3971					var elFonts = $tag.css('font-family');
3972					elFonts = elFonts + ",'Nanum Gothic'";
3973					elFonts = elFonts.replace(/"/g, '\'');
3974					$tag.css('font-family', ($tag.css('font-family') + ",'Nanum Gothic'").replace(/"/g, '\''));
3975				});
3976				$('html').toggleClass('gtoolbar-sticky-ON', $('.cl-gtoolbar[data-sticky="ON"]').length > 0 ? true : false);
3977
3978				if(b.VIEW) {
3979					// prev next
3980					$('.data-page-prev').addClass('active');
3981					$('.data-page-next').addClass('active');
3982
3983					if(b.PARENT.prev === null) $('.data-page-prev').removeClass('active');
3984					if(b.PARENT.next === null) $('.data-page-next').removeClass('active');
3985
3986					if(b.PARENT.mode == 'shopping') {
3987						$('.data-page-prev, .data-page-next').removeClass('active');
3988						if(b.PARENT.prev) $('.data-page-prev').addClass('active');
3989						if(b.PARENT.next) $('.data-page-next').addClass('active');
3990
3991						if(typeof property.PRODINFO === 'object') $.products.display_info();
3992						if($('#review-onoff').val() == 'true') $.products.review(b.VIEW,b.PAGE);
3993						if($('#qna-onoff').val() == 'true') $.products.qna(b.VIEW,b.PAGE);
3994					} else {
3995						if($(`.page-comments[data-id="${b.VIEW}"]`).length == 0) _this.displayComment();
3996
3997						// initViewPageToolbar().then(function(pageToolbar){
3998						// 	setViewPageToolbar();
3999		                // });
4000						initViewPageBottom();
4001					}
4002				}
4003
4004				var isPage = false;
4005				$.each(b.MENULIST, function(i,k) {
4006					isPage = (k.toUpperCase() == b.PAGE.toUpperCase()) ? true : isPage;
4007				});
4008			
4009				// if(!b.ONE && !b.VIEW && !isPage) location.replace(URL);
4010				
4011				// menu ver3 : fheader
4012				if($('header.navbar').hasClass('navbar-fheader')) $.fheader.position();
4013
4014				// shopping wrap remove
4015				if($('.shopping-wrap').length || $('.shopping-more-wrap').length) {
4016					$('.shopping-wrap').remove();
4017					$('.shopping-more-wrap').remove();
4018				}
4019
4020				// shopping wrap create
4021				if(!$('.dsgn-body').hasClass('mode-config') && $('.cl-s-product-detail').length > 0 && $('div[data-el*="el_"]').length > 1) {
4022					if(shopping_more == 'ON') {
4023						var prod_content = $('div[data-el*="el_"]').not('.cl-s-product-detail').addClass('hide');
4024						$('.product.cl-s-product-detail').after('<div class="shopping-wrap open"></div>');
4025						$('.shopping-wrap').html(prod_content);
4026						$('div[data-el*="el_"]').each(function(idx, v) {
4027							$(this).removeClass('hide');
4028							if($('.shopping-wrap').height() > 800) return false;
4029						});
4030					}
4031				}
4032				/*shopping more create*/
4033				if($('.shopping-wrap').length && $('.shopping-wrap').height() >= 800 && $('.shopping-more').length == 0) {
4034					var more_txt = (LANG == 'ko') ? '상품정보 더보기' : 'MORE';
4035					var colorSet = shopping_more_color,
4036						sm_font = (!colorSet) ? '' : colorSet.color,
4037						sm_bgColor = (!colorSet) ? '' : colorSet.background_color,
4038						sm_border = (!colorSet) ? '' : colorSet.border_color;
4039					var review_chk = ($('.cl-s-product-review').length > 0) ? true : false,
4040						qna_chk = ($('.cl-s-product-qna').length > 0) ? true : false;
4041
4042					$('.shopping-wrap').css('max-height','800px')
4043									   .css('overflow','hidden')
4044									   .after('<div class="shopping-more-wrap"><div class="shopping-more">'+more_txt+'</div></div>');
4045					$('.shopping-wrap').removeClass('open');
4046					if(sm_font) $('.shopping-more').css('color',sm_font);
4047					if(sm_bgColor) $('.shopping-more').css('background-color',sm_bgColor);
4048					if(sm_border) $('.shopping-more').css('border-color',sm_border);
4049					if(!review_chk && !qna_chk) $('.shopping-more-wrap').css('padding-bottom','100px');
4050				}
4051
4052				$('.el-footer').show();                
4053
4054				if($('.element a[data-popup][data-popup-name]').length > 0 && (!b.VALIDPLAN || b.VALIDTYPE == 'PK')) {
4055					$('.element a[data-popup][data-popup-name]').addClass('disabled');
4056				}
4057
4058				if($('.element[data-layout]').length > 0) {
4059					setLayoutHeight();
4060				}
4061				setBlockParallax($('.element'));
4062				if(!pageMoveAOSPending && $('.element[data-aos]').length > 0) {
4063					if(typeof refreshBlockAOSNow == 'function') {
4064						refreshBlockAOSNow();
4065						scheduleBlockAOSRefresh(250);
4066					} else scheduleBlockAOSRefresh(0);
4067				}
4068				moveToLoadedTabmenuSection(currentPAGE, 0);
4069				if(pageMoveAOSPending) {
4070					pageMoveAOSDrawReady = true;
4071					finishPageMoveAOS();
4072				}
4073				
4074				if(typeof fbq == 'function' && b.VALIDTYPE == 'SM') {
4075					if(b.VIEW) {
4076						var checkProduct = (b.PAGE.match(/^forum,/g) === null && typeof b.PARENT != 'undefined' && typeof b.PARENT.mode != 'undefined' && b.PARENT.mode == 'shopping') ? true : false,
4077							mn = (b.ONE) ? b.PARENT.opage : b.PARENT.ppage;
4078						if(checkProduct && typeof callbackEvtViewContent == 'function') callbackEvtViewContent(mn,b.PARENT.seq,b.PARENT.title,$('.total-price').text().replace(/[^0-9]/g,''));
4079					} else {
4080						var checkProductList = ($('.element[data-type="gallery"][data-mode="shopping"]').length > 0) ? true : false;
4081						if(checkProductList && typeof callbackEvtLead == 'function') callbackEvtLead(b.PAGE);
4082					}
4083				}
4084
4085				deferred.resolve();
4086			});
4087
4088			return deferred.promise();
4089		}
4090
4091		var elPush = function (prop) {
4092		    /* prop - reorder list hide */
4093		    var pageID = b.PAGE.split(','),
4094		        chgBG = false,
4095		        tmpTag = '',
4096		        currentPAGE = '',
4097		        default_t_css = '', default_m_css = '';
4098		    var checkGalleryView = (b.VIEW && b.PAGE.match(/^forum,/g) === null) ? true : false;
4099		    var block_display = (typeof b.SETTINGS.block_display != 'undefined' && b.SETTINGS.block_display) ? b.SETTINGS.block_display : {},
4100		    	footer_display = (typeof block_display.footer_display != 'undefined' && block_display.footer_display) ? block_display.footer_display : 'ON',
4101		    	checkFooterDisplay = (footer_display != 'OFF') ? true : false;
4102
4103				currentPAGE = b.PAGE;
4104				var contentsParam = (currentPAGE=='index,template' && param.indexOf('/org/') == -1) ? param + '/org/' + b.PAGE : param;
4105
4106			if(b.VALIDPLAN && $.inArray(b.VALIDTYPE, ['BN','SM']) > -1 && b.CERT_USE == 'Y') {
4107    			if(b.CERT_USE == 'Y') {
4108    				if(b.UMEMBER.check_login == true) isUserCertified(history);
4109    			}
4110    		}
4111	        if(pageID[0] == 'forum' && b.VIEW) {
4112		    	clearDsgnbody();
4113
4114				var preloading = loadingScript({'forum':true});
4115				preloading.done(function() {
4116					var ps_fmview = $.forum.view(b.VIEW);
4117					ps_fmview.done(function(data) {
4118						_this.displayComment(data);
4119						if(b.VIEW) setViewPageToolbar();
4120						$('.el-footer').show().css('visibility', 'visible');
4121						$.processOFF();
4122						$('.dsgn-body').animate({scrollTop: 0}, 0,'easeInOutQuart'); 
4123					}).fail(function(error_msg) {
4124						// console.log(error_msg);
4125						$.processOFF();
4126					});
4127				});
4128				return false;
4129	        }
4130
4131				if(b.pageContent.hasOwnProperty(currentPAGE)) {
4132					if(b.pageInitContent.hasOwnProperty(currentPAGE)) property.INITPAGE = b.pageInitContent[currentPAGE];
4133					var loadCachedContents = function() {
4134						var loadingContents = loadPush(b.pageContent[currentPAGE]);
4135						loadingContents.then(function() {
4136							$('.el-footer').css('visibility', 'visible');
4137							$.processOFF();
4138						});
4139					};
4140					if(b.pageBlocksType.hasOwnProperty(currentPAGE)) {
4141						var preloading = loadingScript(b.pageBlocksType[currentPAGE]);
4142						preloading.then(loadCachedContents);
4143					} else {
4144						loadCachedContents();
4145					}
4146		        } else {
4147					contentsParam = (b.PUBLISH) ? contentsParam : contentsParam + '/render/true';
4148					if(checkGalleryView) $('.el-footer').addClass('hide');
4149					$.ajax({
4150						url: '/template/contents/sid/' + b.SID + '/page/' + encodeURIComponent(currentPAGE) + contentsParam,
4151						data: { siteum: b.SITEUM },
4152						dataType: 'json',
4153						type: 'GET',
4154						async: true,
4155						success: function(data) {
4156							if(data && typeof data.url != 'undefined' && data.url) {
4157								location.href = data.url;
4158								return;
4159							}
4160							if(!data || (typeof data.error != 'undefined' && data.error)) {
4161								if(currentPAGE!='index,template') {
4162									alert($.lang[LANG]['page.not.found']);
4163									location.replace('/');
4164								}
4165								return;
4166							}
4167							if(currentPAGE!='index,template') b.pageContent[currentPAGE] = data.contents;
4168							if(data.conf) b.pageConf[currentPAGE] = data.conf;
4169							if(typeof data.blocks_type != 'undefined') b.pageBlocksType[currentPAGE] = data.blocks_type;
4170							if(data.initContent !== undefined) {
4171								property.INITPAGE = JSON.parse(data.initContent);
4172								b.pageInitContent[currentPAGE] = property.INITPAGE;
4173							}
4174
4175							var drawLoadedContents = function() {
4176								var preloading = loadingScript(data.blocks_type);
4177								preloading.then(function() {
4178									var loadingContents = loadPush(data.contents);
4179									loadingContents.then(function() {
4180										$('.el-footer').css('visibility', 'visible');
4181										if(checkFooterDisplay && $('.el-footer').hasClass('hide')) $('.el-footer').removeClass('hide');
4182										$.processOFF();
4183									});
4184								});
4185							};
4186
4187							if(data.conf && applyPageConf(data.conf) === false) return;
4188							if(b.ISLOCK == 'true') {
4189								isMenuLock(function() {
4190									if(b.ISLOCK != 'true') drawLoadedContents();
4191									else {
4192										$('.el-footer').css('visibility', 'visible');
4193										$.processOFF();
4194									}
4195								});
4196							} else {
4197								drawLoadedContents();
4198							}
4199						}
4200					});
4201	        }
4202		}
4203
4204		var scrollspy = function() {
4205		    if(!b.ONE) return false;
4206		    var top = 0,
4207		        active = '';
4208
4209		    // top = ($('.dsgn-body').hasClass('sidebar')) ? 0 : $('.el-menu header').outerHeight();
4210
4211		    $.each(b.MENULINK,function(i,v) {
4212
4213		        var $el = ($.inArray(v,property.MENULIST) > -1) ? getRenderOnepagePageBlock(v) : '';
4214		        if($el.length>0) {
4215		            var offset = $el.offset();
4216		           top = ($('.dsgn-body').hasClass('sidebar')) ? 0 : $('.el-menu header').outerHeight();
4217		            if((Math.floor(offset.top) - $(document).scrollTop())<= top) {		            	
4218		            	active = v;
4219		            }
4220		        }
4221
4222		    });
4223
4224		    
4225			if(!$('#tpl-menu li a[href="#'+active+'"]').parent().hasClass('active')) {
4226				
4227				$('#tpl-menu li').removeClass('active').removeClass('open');
4228				
4229				$('#tpl-menu li a[href="#'+active+'"]').parent().addClass('active');
4230				if( $('#tpl-menu li a[href="#'+active+'"]').closest('.dropdown-menu').length>0 ) {
4231					if($('body').width() > 768) $('#tpl-menu li a[href="#'+active+'"]').closest('.dropdown').addClass('active');
4232					else {
4233						//원페이지일 때 769~783 해상도에서 갤러리 위에 마우스 올리면 하위메뉴 열리는 현상 있어서 모바일에서만 open 클래스 추가 되도록 #mobile-nav 코드 추가.
4234						$('#mobile-nav #tpl-menu li a[href="#'+active+'"]').closest('.dropdown').addClass('open');
4235					}
4236				}
4237			}
4238
4239		    if($(document).scrollTop() + $('body').height() == $('body').prop('scrollHeight')) {
4240
4241		        var last = b.MENULINK[b.MENULINK.length-1],
4242		            $el = ($.inArray(last,property.MENULIST) > -1) ? getRenderOnepagePageBlock(last) : '';
4243
4244		        if($el.length>0) {
4245		            if($el.offset().top>top) {
4246		                $('#tpl-menu li').removeClass('active').removeClass('open');
4247		                
4248		                if($(document).scrollTop()!=0) 
4249		                	$('#tpl-menu li a[href="#'+last+'"]').parent().addClass('active');
4250
4251						if($('#tpl-menu li a[href="#'+last+'"]').closest('.dropdown-menu').length>0) {
4252							if($('body').width() > 768) $('#tpl-menu li a[href="#'+last+'"]').closest('.dropdown').addClass('active');
4253							else $('#tpl-menu li a[href="#'+last+'"]').closest('.dropdown').addClass('open');
4254						}
4255		            }
4256		        }
4257		    }
4258
4259		}
4260
4261		var fixedMenu = function() {
4262			if($.clnav.check()) return;
4263
4264			if($('header.navbar').hasClass('navbar-fheader')) { // menu ver3 : fheader 
4265				if($('body').is('[data-gjs^="fixedscroll"]')) {
4266					return false;
4267				}
4268
4269				var isSidebar = $('.el-menu > header').hasClass('sidebar');
4270				if($(document).scrollTop() > $('header.navbar').height()) {
4271					if(window.innerWidth > 768) {
4272						$('.menu-logo-top').hide();
4273						$('.el-menu').addClass('fixed-fheader');
4274					}
4275					if(b.HEADER && !isSidebar)  $('header.navbar').removeClass('transparent');
4276				} else if($(document).scrollTop() <= $('header.navbar').height()) {
4277					$('.el-menu').removeClass('fixed-fheader');
4278					$('.menu-logo-top').show();
4279					
4280					if(b.HEADER && !isSidebar) {
4281						$('header.navbar').addClass('transparent');
4282						$('.dsgn-body').css('padding-top','0px');
4283					}
4284				}
4285
4286				return false;
4287			}
4288
4289		    header_fixed = $('.header.el-menu').height();
4290		    var user_menu = $('.el-menu');
4291			var menu_color = $('header.navbar').css('background-color');
4292			var menu_bg_img = (typeof $('header.navbar').css('background-image') != 'undefined') ? $('header.navbar').css('background-image') : 'none';
4293			var menu_bg_position = (typeof $('header.navbar').css('background-position') != 'undefined') ? $('header.navbar').css('background-position') : 'center center';
4294			var menu_bg_repeat = (typeof $('header.navbar').css('background-repeat') != 'undefined') ? $('header.navbar').css('background-repeat') : 'no-repeat';
4295			var menu_bg_size = (typeof $('header.navbar').css('background-size') != 'undefined') ? $('header.navbar').css('background-size') : 'cover';
4296
4297		    if($(document).scrollTop() > header_fixed && user_menu.hasClass('fixed')==false && !$('.dsgn-body').hasClass('sidebar')) {
4298		        user_menu.fadeOut('fast', function() {
4299		            $(this).addClass('fixed').fadeIn('fast');
4300		            $('.fixed').addClass('fixed-position');
4301		            if(!b.HEADER || $('header.navbar').hasClass('sidebar') ) {
4302	                	var topval = ($('.creatorlink-header').length==1) ? '55px' : '0';
4303		            	$('.el_0').css('margin-top',topval);
4304		                var $header_empty = $('<div class="header-empty"></div>');
4305		                if($(".header-empty").length==0) {
4306		                	var topval = ($('.creatorlink-header').length==1) ? '55px' : '0';
4307			                $header_empty.css({
4308			                    'background-color' : $('header.navbar').css('background-color'),
4309								'background-image' : menu_bg_img,
4310								'background-position' : menu_bg_position,
4311								'background-repeat' : menu_bg_repeat,
4312								'background-size' : menu_bg_size,
4313			                    //'position' : 'relative',
4314			                    'width' : '100%',
4315			                    'height' : header_fixed+'px',
4316			                    'top' : topval,
4317			                    'z-index' : '1'
4318			                });
4319			                $('.dsgn-body').prepend($header_empty);
4320			            }
4321       		        	$('.header-empty').css('position','relative');
4322		            } else {
4323		            	$('header.navbar').removeClass('transparent');
4324		            }
4325		            if(window.innerWidth > 768) $('.menu-logo-top').hide();
4326		        });        
4327		    } else if($(document).scrollTop() < header_fixed && user_menu.hasClass('fixed') && !$('.dsgn-body').hasClass('sidebar')){
4328		        user_menu.fadeOut('fast', function(){
4329			        $('.header-empty').css('position','absolute');
4330		            $('.fixed').addClass('fixed-position');
4331		            user_menu.removeClass('fixed').fadeIn('fast');
4332		            if(!b.HEADER  || $('header.navbar').hasClass('sidebar') ) {
4333		            	$('.el_0').css('top','0');
4334		            } else {
4335		            	$('header.navbar').addClass('transparent');
4336		            	if($('.creatorlink-header').length == 1) $('div.header.fixed-position').addClass('top-zero');
4337		            }
4338		            $('.menu-logo-top').show();
4339		        });
4340		    }
4341		}
4342
4343		var elFooter = function() {
4344			if(typeof b.pageContent[b.PAGE] == 'undefined' && $('.error_404.new_design').length > 0) $('.error_404.new_design').remove();
4345			if($('.el-footer').length > 0) {
4346				setTimeout(function() { 
4347					if($('.element:not(.el-footer)').length < 1 && !(b.MENULIST.indexOf(b.PAGE) > -1) && !b.ONE && !b.VIEW) {
4348						if($('.error_404.new_design').length == 0) {
4349							$('style#el-footercss').after(error_style);
4350							$('.element.el-footer').before(error_html); //404 error
4351						}
4352					}
4353					$('.el-footer').show(); 
4354				}, 300);
4355				return false;
4356			}
4357			
4358			if(b.FTAG == '') b.FTAG = '<div class="footer-' + b.SID + '"></div>';
4359		    $footer = $(b.FTAG);
4360		    $footer.find('.link-site-home').prop('href',URI); 
4361		    $footer.addClass('element')
4362		           .addClass('el-footer')
4363		           .addClass('hide')
4364		           .attr('data-type','footer')
4365		           .attr('data-el','el-footer')
4366		           .attr('data-id','footer')
4367		           .attr('data-name','footer-' + b.SID);
4368
4369		    $footer.appendTo($('.dsgn-body'));
4370		    $('.dsgn-body').prepend('<style id="el-footercss">' + b.FCSS + '</style>');
4371
4372			/*180822 add*/
4373			// before v1 creatorlink-box remove
4374			if($('.el-footer').find('.creatorlink-box').length > 0 ) {
4375				if($('.el-footer').find('.creatorlink-box').prev().hasClass('col-md-10')) $('.el-footer').find('.creatorlink-box').prev().removeClass('col-md-10').addClass('col-md-12');
4376				$('.el-footer').find('.creatorlink-box').remove();
4377			}
4378			// before v2 creatorlink-footer remove
4379			if( $('.el-footer').find('.creatorlink-footer').length > 0) {
4380				$('.el-footer').find('.creatorlink-footer').remove();
4381			}
4382
4383			// made it with Creatorlink
4384			if(!b.VALIDPLAN || b.VALIDTYPE == 'PK') {
4385				var is_templates = checkTemplateSite(b.SID);
4386				if(!is_templates) {
4387					$('.goto-top').addClass('moved');
4388					setMadeWithCreatorlink();
4389				}	
4390			}
4391
4392			setCLEscrowFooter(b.SID, b.VALIDTYPE, b.SETTINGS.sm_escrow);
4393
4394		 	var isfooterAttach = typeof $footer.attr('data-flogo') == 'undefined' ? false : $footer.attr('data-flogo'),
4395	 		   	checkFixTypeMenu = (typeof $('header.navbar-fheader').attr('data-fixtype') != 'undefined' && $('header.navbar-fheader').attr('data-fixtype')) ? true : false;
4396
4397	    	if(isfooterAttach) {
4398				if(b.ONE){
4399					if(b.VIEW) $footer.find('#site-home-footer').attr('href',URI).removeClass('mini-home');
4400					else $footer.find('#site-home-footer').attr('href','javascript:;').addClass('mini-home');
4401				} else $footer.find('#site-home-footer').attr('href',URI).removeClass('mini-home');
4402			}
4403
4404	    	/*var block_display = (typeof b.SETTINGS.block_display != 'undefined' && b.SETTINGS.block_display) ? b.SETTINGS.block_display : {},
4405        		footer_display = (typeof block_display.footer_display != 'undefined' && block_display.footer_display) ? block_display.footer_display : 'ON';
4406
4407			if(footer_display=='OFF') $('.footer-'+b.SID+'.el-footer').hide();*/
4408
4409			/*180822  delete - powered by Creatorlink
4410			// before creatorlink-box remove
4411			if($('.el-footer').find('.creatorlink-box').length > 0 ) { 
4412				if($('.el-footer').find('.creatorlink-box').prev().hasClass('col-md-10')) $('.el-footer').find('.creatorlink-box').prev().removeClass('col-md-10').addClass('col-md-12');
4413				$('.el-footer').find('.creatorlink-box').remove();
4414			}
4415
4416			if($('.el-footer').find('*[data-edit="true"]').first().closest('.row').children('div').length == 1 &&
4417				$('.el-footer').find('*[data-edit="true"]').first().closest('.row').children('div').hasClass('col-md-10') ) {
4418				$('.el-footer').find('*[data-edit="true"]').first().closest('.row').children('div').removeClass('col-md-10').addClass('col-md-12');
4419			}
4420
4421			if(typeof b.VALIDPLAN != 'undefined' && b.VALIDPLAN && b.VALIDTYPE != 'PK') {
4422				if( $('.el-footer').find('.creatorlink-footer').length > 0 ) $('.el-footer').find('.creatorlink-footer').remove();
4423			} else {
4424				var el_f_style = $('.el-footer').attr('style');
4425				if(typeof el_f_style != 'undefined' && 
4426					(el_f_style.indexOf('display') > -1 || el_f_style.indexOf('opacity') > -1 || el_f_style.indexOf('z-index') > -1) ) $('.el-footer').removeAttr('style');
4427				if($('.el-footer').css('display') == 'none') $('.el-footer').css('display','block');
4428				if($('.el-footer').css('opacity') < 1) $('.el-footer').css('opacity',1);
4429				if($('.el-footer').css('z-index') != 'auto') $('.el-footer').css('opacity','auto');
4430
4431				if( $('.el-footer').find('.creatorlink-footer').length == 0) setFooterCretorlinkBox();
4432				setFooterLink();
4433			}
4434			*/
4435			if($('.element:not(.el-footer)').length < 1 && !(b.MENULIST.indexOf(b.PAGE) > -1) && !b.ONE && !b.VIEW && b.PAGE != 'psearch') {
4436				show404();
4437			}
4438
4439			changeBrokenImages($footer);
4440
4441		    if(!b.FTAG || b.FOOTER) {
4442		        // $footer.hide();
4443		    } else {
4444		    	if(b.VIEW && b.PARENT.mode == 'shopping' && $(document).width() < 768) {
4445		    		$('.el-footer').css('margin-bottom','55px');
4446		    	}
4447
4448		    	var block_display = (typeof b.SETTINGS.block_display != 'undefined' && b.SETTINGS.block_display) ? b.SETTINGS.block_display : {},
4449		        	footer_display = (typeof block_display.footer_display != 'undefined' && block_display.footer_display) ? block_display.footer_display : 'ON';
4450
4451	        	if(footer_display!='OFF') {
4452			    	setTimeout(function() {
4453			    		$footer.removeClass('hide');
4454			    	},300);
4455			    }
4456
4457			    setTimeout(function(){
4458					if(checkFixTypeMenu) {
4459						if(b.VALIDPLAN) setFixedMenuCss(false);
4460						else {
4461							$('.el-menu header.navbar[data-fixtype]').find('#tpl-menu').css({
4462								'width': '100%'
4463							});
4464						}
4465					} 
4466			    },80);
4467		    }
4468		}
4469
4470		function setDefaultValue(value) {
4471			return (typeof value == 'undefined') ? '' : value;
4472		}
4473
4474		function setDefaultValueEtc(type, el) {
4475			type = (typeof el.attr('data-contact-etc-type') != 'undefined' && el.attr('data-contact-etc-type') ) ? el.attr('data-contact-etc-type') : type;
4476            
4477            var input_type = ['text','email','number','tel','url'];
4478            if($.inArray(type,input_type)) {
4479				return (typeof el.val() == 'undefined') ? '' : el.val();
4480			} else if(type == 'checkbox') {
4481				return ( el.prop('checked') ) ? 'O' : 'X';
4482			} else if(type == "radio") {
4483				return el.find('input:radio:checked').val();
4484			} else if(type == 'selectbox') {
4485				var result = (el.find('option').length > 0 ) ? el.find('option:checked').val() : el.find('.active').find('.opval').text();
4486				return result;
4487			} else {
4488				return 'etc article';
4489			}
4490		}
4491
4492		$(document).off('contactSubmitSecurityUpdate.render').on('contactSubmitSecurityUpdate.render', function(e, $contactEL, pid, settings, blocklang) {
4493			setContactSubmitSecurity($contactEL, pid, settings, blocklang);
4494		});
4495
4496		function setDefaultForm(el) {
4497			var ch_lang = getLang($(el + ' [form-idx]'), b.SID);
4498    		var type2 = $(el).attr('data-type2');
4499			
4500			$(el + ' [form-idx]').val('');
4501			$(el + ' [form-idx]').find('.form-date').val('');
4502			$(el + ' [form-idx]').find('.form-date').removeAttr('style')
4503			$(el).find('input:checkbox').removeAttr('checked');
4504			$(el).find('input:radio').removeAttr('checked');
4505			$(el).find('.checkbox-inline').removeClass('checked');
4506    		$(el).find('.radio-inline').removeClass('checked');
4507			$(el + ' [form-type="file.upload"]').find('label .file-uploaded-number').text('(0/10)');
4508			$(el + ' [form-type="file.upload"]').find('input[type="file"]').val('');
4509            $(el + ' [form-type="file.upload"]').find('input[type="text"]').val('');
4510            $(el + ' [form-type="file.upload"]').find('.file-title').text($.lang[ch_lang]['form.file.nofile']);
4511
4512            if($(el + ' [form-type="file.upload"]').find('.file-row').length > 0) {
4513            	$(el + ' [form-type="file.upload"]').find('.file-row').remove();
4514            	$(el + ' [form-type="file.upload"]').find('.file-uploaded-number').text('(0/10)');
4515		    	$(el + ' [form-type="file.upload"]').find('.file-title').removeClass('hide');
4516            }
4517
4518            if(type2 == 'form' && $(el).attr('data-captcha') != 'false' && $(el).find('input.input-captcha').length > 0) {
4519            	$(el).find('input.input-captcha').val('');
4520            	load_form_kcaptcha($(el), $(el).attr('data-id'));
4521            }
4522
4523            if($(el).attr('data-type2') == 'franchise bar') {
4524		        $(el).find('.view-privacy').removeClass('active');
4525		        $(el).find('.franchise-form-select').each(function() {
4526		            var defaultText = $(this).attr('form-name') || $(this).find('select.franchise-form-select-native option:first').text();
4527		            $(this).find('select.franchise-form-select-native').val('');
4528		            $(this).find('.franchise-form-select-label').text(defaultText).removeClass('selected');
4529		            $(this).find('.dropdown-menu li').removeClass('active');
4530		        });
4531		        // $(el).find('.form-privacy textarea').hide();
4532		    }
4533		}
4534
4535		function setDefaultContactForm(el) {
4536			$(el + ' [data-contact-firstname]').val('');
4537			$(el + ' [data-contact-lastname]').val('');
4538			$(el + ' [data-contact-email]').val('');
4539			$(el + ' [data-contact-website]').val('');
4540			$(el + ' [data-contact-phone]').val('');
4541			$(el + ' [data-contact-subject]').val('');
4542			$(el + ' [data-contact-message]').val('');
4543			$(el).find('input:checkbox').removeAttr('checked');
4544			$(el).find('input:radio').removeAttr('checked');
4545			$(el + ' [form-type="file.upload"]').find('input[type="file"]').val('');
4546            $(el + ' [form-type="file.upload"]').find('input[type="text"]').val('');
4547            $(el + ' [form-type="file.upload"]').find('.file-title').text("첨부된 파일이 없습니다.");
4548
4549			if($(el).attr('data-captcha') == 'true' && $(el).find('input.input-captcha').length > 0) {
4550				$(el).find('input.input-captcha').val('');
4551				$(el).find('.form-captcha .error').remove();
4552				load_form_kcaptcha($(el), $(el).attr('data-id'));
4553			}
4554		}
4555
4556		function setDefaultContactFormEtc(el) {
4557			$(el).find('[data-contact-etc]').each(function(i) {
4558				var type = (typeof $(this).attr('data-contact-etc-type') != 'undefined' && $(this).attr('data-contact-etc-type') ) ? $(this).attr('data-contact-etc-type') : $(this).attr('type');
4559				
4560				var input_type = ['text','email','number','tel','url'];
4561				if($.inArray(type,input_type)) {
4562					$(this).val('');
4563				} else if(type == "checkbox") {
4564					$(this).removeAttr('checked');
4565				} else if(type == "radio") {
4566					$(this).find('input:radio').first().click();
4567				} else if(type == "selectbox") {
4568					if($(this).find('option').length > 0) {
4569						$(this).find('option:first').attr('selected','selected');
4570					} else {
4571						$(this).find('.active').removeClass('active');
4572						$(this).find('li').first().addClass('active');
4573					}
4574				}
4575			});
4576		}
4577
4578		var ieLineClamp = function() {
4579		    if(isIE()) {
4580		        $('[data-ie-clamp]').each(function(index, element) {
4581		            var clamp = $(this).attr('data-ie-clamp').split(','),
4582		                line = new Array();
4583
4584		            $.each(clamp,function(k,v) {
4585		                line.push(v);
4586		            });
4587
4588		            for(i=line.length; i<3; i++) line[i] = 0;
4589		            var idx = getScreenIndex();
4590		            var apply = line[idx];
4591
4592		            // console.log($(element).text());
4593		            //safeClamp(element, apply);
4594		            $clamp(element, {clamp:apply, useNativeClamp:false });
4595		        });
4596		    }
4597		}
4598
4599		var safeClamp = function (selector, lines) {
4600			lines = lines || 3; // a default
4601			$(selector).each( function() {
4602				if($(this).text()) {
4603					$clamp( this, { clamp: lines, useNativeClamp:false  });
4604				}
4605			});
4606		}
4607
4608		$('.data-page-back, .toolbar-btn.back').live({
4609		    click : function() {
4610				var pPage = (b.ONE && b.PARENT.opage) ? b.PARENT.opage : b.PARENT.page;
4611				var page = b.PAGE.split(',');
4612				var inMenu = ($.inArray(pPage,b.MENULIST) == -1 && page[0] != '_product') ? false : true;
4613
4614				if(!inMenu) {
4615					$(this).showModalFlat('INFORMATION','이동할 수 없습니다',true,false,'','ok');
4616					return false;
4617				} else {
4618					setGalleryReturnItemCookie(b.PARENT);
4619					if($.cookie('gallery') !== undefined && $.cookie('gallery') == 'all_products') {
4620						var c_g_p = (typeof $.cookie('gallery-page-all_products') != 'undefined') ? $.cookie('gallery-page-all_products') : 1;
4621				    	$.cookie('gallery', 'all_products', { path: '/', expires: 12 * 60 * 60 * 1000 });
4622				    	$.cookie('loadmore-all_products', c_g_p, { path: '/', expires: 12 * 60 * 60 * 1000 });
4623				    	
4624				    	var url_replace = (b.URL == '/') ? '' : b.URL;
4625				    	if(b.ONE) {
4626				    		_this.history.pushState(null,b.TITLE,url_replace + '/index#전체상품');
4627				    	} else {
4628				    		_this.history.pushState(null,b.TITLE,url_replace + '/전체상품');
4629				    	}
4630					} else {
4631						var c_g_p = (typeof $.cookie('gallery-page-' + b.PARENT.pid) != 'undefined') ? $.cookie('gallery-page-' + b.PARENT.pid) : 1;
4632				    	$.cookie('gallery',b.PARENT.pid, { path: '/', expires: 12 * 60 * 60 * 1000 });
4633				    	$.cookie('loadmore-' + b.PARENT.pid, c_g_p, { path: '/', expires: 12 * 60 * 60 * 1000 });
4634				    	
4635				    	var url_replace = (b.URL == '/') ? '' : b.URL;
4636				    	if(b.ONE) {
4637						_this.history.pushState(null,b.TITLE,url_replace + '/index#' + pPage);
4638				    	} else {
4639				    		var page = b.PAGE.split(',');
4640				    		if(page[1]=='template') {
4641					    		_this.history.pushState(null,b.TITLE,url_replace + '/' + page[0]);
4642				    		} else {
4643					    		_this.history.pushState(null,b.TITLE,url_replace + '/' + b.PARENT.page);
4644				    		}		    		
4645				    	}
4646					}
4647					
4648			    }
4649		    }
4650		});
4651
4652	    $('#config-mode-view').click(function() {
4653	    	location.href = '//' + b.HOST + b.REFERER;
4654	    });
4655
4656		$('body')
4657			.on('click','.mini-home, #goto-top, #quick-menu-top', function(event) { 
4658				event.preventDefault(); 
4659				$('body,html').animate({scrollTop: 0}, 900,'easeInOutQuart'); 
4660			})
4661			.on('click','#quick-menu-bottom', function(event) { 
4662				event.preventDefault(); 
4663				$('body,html').animate({scrollTop: document.body.scrollHeight}, 900,'easeInOutQuart'); 
4664			});
4665
4666		var moveGallerySibling = function(seq, gallerySettings, page) {
4667			var settings = {};
4668			if(gallerySettings) {
4669				try {
4670					settings = (typeof gallerySettings == 'string') ? $.parseJSON(gallerySettings) : gallerySettings;
4671				} catch(e) {
4672					settings = {};
4673				}
4674			}
4675
4676			var glink = (settings && settings.glink) ? settings.glink : '';
4677			if(!glink || b.PARENT.mode != 'project') {
4678				var url_replace = (b.URL == '/') ? '' : b.URL;
4679				_this.history.pushState(null,b.TITLE,url_replace + '/' + page + '/view/' + seq);
4680				return;
4681			}
4682
4683			try {
4684				if(checkBase64Encode(decodeURIComponent(glink))) glink = Base64.decode(decodeURIComponent(glink));
4685				else if(checkBase64Encode(glink)) glink = Base64.decode(glink);
4686			} catch(e) {
4687				if(checkBase64Encode(glink)) glink = Base64.decode(glink);
4688			}
4689
4690			var target = (settings.glink_target == '_blank') ? '_blank' : '';
4691			var linkModal = $(this).showModalFlat(
4692				$.lang[LANG]['config.information'],
4693				$.lang[LANG]['gallery.sibling.link.confirm'],
4694				true,
4695				true,
4696				function() {
4697					var linkUrl = makeLinkUrl(glink, b.ONE, b.VIEW);
4698					var $link = $('<a></a>').attr('href', linkUrl).css('display', 'none');
4699
4700					if(glink.match(/^\@/g) !== null) {
4701						$link.attr('attr-bookmark', glink.replace(/^\@/g, ''));
4702					} else if(glink.match(/^flink\@[0-9]/gi) !== null) {
4703						$link.attr('attr-flink', glink.replace(/^flink\@/gi, ''));
4704					} else if($.inArray(glink.replace(/^\//g, '').replace(/ /g, '-'), b.MENULIST) > -1) {
4705						$link.attr('data-user-link', linkUrl);
4706					} else {
4707						$link.attr('attr-link', glink);
4708					}
4709
4710					if(target) $link.attr('target', target);
4711					$('body').append($link);
4712					$link[0].click();
4713					setTimeout(function() { $link.remove(); }, 0);
4714					linkModal.modal('hide');
4715				},
4716				'cancel',
4717				'ok'
4718			);
4719		};
4720
4721		$('.data-page-prev').live({
4722		    click : function(e) {
4723		        var page = b.PAGE.split(',');
4724		    	if(!$(this).hasClass('active') || b.PARENT.prev === null) return false;
4725		    	if(typeof b.PARENT.page == 'string' && $.inArray(b.PARENT.page,b.MENULIST) == -1 && page[0] != '_product') return false;
4726		    	if(b.PARENT.prev)
4727					moveGallerySibling(b.PARENT.prev, b.PARENT.prev_gsettings, page[0]);
4728		    }
4729		});
4730
4731		$('.data-page-next').live({
4732		    click : function() {
4733		        var page = b.PAGE.split(',');
4734		    	if(!$(this).hasClass('active') || b.PARENT.next === null) return false;
4735		    	if(typeof b.PARENT.page == 'string' && $.inArray(b.PARENT.page,b.MENULIST) == -1 && page[0] != '_product') return false;
4736		    	if(b.PARENT.next)
4737					moveGallerySibling(b.PARENT.next, b.PARENT.next_gsettings, page[0]);
4738		    }
4739		});
4740
4741		// [oldver Menu nav link] Click
4742		$(`#tpl-menu.nav > li:not(.siteUM,.siteLANG) a:not([href="javascript:;"]):not([href*="flink@"]),
4743			.cl-moption > .cl-moption-col > .cl-moption-row > a:not([href="javascript:;"]):not([href*="flink@"]),
4744			.el-menu header.navbar a#site-home
4745		`).live({
4746		    click : function(e) {
4747		    	e.preventDefault();
4748				if(typeof e.target.className == 'string' && e.target.className.indexOf('fa') > -1 && $(this).closest('header').hasClass('navbar-simple')) { 
4749					return false; 
4750				}
4751				if(typeof $(this).attr('data-toggle') != 'undefined') { return false; }
4752
4753				$.each($.cookie(), function(i,v) {
4754					if(i.indexOf('gallery-category-') > -1) {
4755						var gallery_seq = i.replace('gallery-category-','');
4756						var gcate_home = (typeof $.cookie('gallery-catehome-' + gallery_seq) == 'undefined') ? '' : $.cookie('gallery-catehome-' + gallery_seq);
4757						$.cookie(i, gcate_home, { path : '/', expires: 12 * 60 * 60 * 1000 });
4758					}
4759					if(i.indexOf('gallery-page-') > -1) $.cookie(i, 1, { path : '/', expires: 12 * 60 * 60 * 1000 });
4760					if(i.indexOf('loadmore-') > -1) $.cookie(i, 1, { path : '/', expires: 0 });
4761				});
4762
4763				$.removeCookie('gallery', { path: '/' });
4764				$.removeCookie('gallery-item', { path : '/' });
4765				$.removeCookie('forum', { path : '/' });
4766				$.removeCookie('forum-item', { path : '/' });
4767
4768				var isClickMoption = ($(this).closest('.cl-moption-col').length > 0) ? true : false;
4769				var isClickSiteHome = (typeof $(this).attr('id') != 'undefined' && $(this).attr('id') == 'site-home') ? true : false;
4770
4771				var menuVer06 = ($('.el-menu .cl-menu-option').length > 0) ? true : false;
4772				var menuVer03 = ($('.el-menu > header').hasClass('navbar-fheader')) ? true : false;
4773				var menuVer02 = (!menuVer03 && $('.el-menu > header').hasClass('navbar-simple')) ? true : false;
4774				var menuVer01 = (!menuVer03 && !menuVer02) ? true : false;
4775
4776				if($('body').width() < 769)  {
4777					var clickNavbarToggle = ( (menuVer03 && $('.navbar-toggle').css('visibility') == 'hidden') && !isClickSiteHome ||
4778											  (menuVer02 && !isClickSiteHome) ||
4779											  menuVer01
4780											) ? true : false;
4781					if(clickNavbarToggle) $('.navbar-toggle').click();
4782				}
4783
4784				if(isClickMoption && !property.ONE) $(this).closest('header').find('.cl-menu-option').removeClass('open');
4785				if(!isClickSiteHome) {
4786					if($(this).hasClass('loginout')) {
4787						if(b.URL == '/render') {
4788							$(this).showModalFlat('INFORMATION','미리보기에서는 제공되지 않습니다.',true,false,'','ok');
4789							return false;
4790						}
4791						$('#loginModal').modal('show');
4792						$('#loginModal').css('z-index',1042);
4793						$('.modal-backdrop.fade.in').css('z-index', 1041);
4794					} else {
4795						$('#tpl-menu li').removeClass('active').removeClass('open');
4796						$(this).parent().addClass('active');
4797
4798						if($(this).closest('.dropdown-menu').length>0) {
4799							if($('body').width() > 768) {
4800								$(this).closest('.dropdown').addClass('active').siblings().removeClass('active');
4801							} else {
4802								if(menuVer03) {
4803									$(this).closest('.menu-has-children').addClass('open').siblings().removeClass('open');
4804									$('#tpl-menu .menu-has-children:not(.open) ul.dropdown-menu').hide();
4805								} else {
4806									$(this).closest('.dropdown').addClass('open').siblings().removeClass('open');
4807									$('#tpl-menu .dropdown:not(.open) ul.dropdown-menu').hide();
4808								}
4809							}
4810						} else {
4811							if(menuVer03) $('#mobile-nav li.menu-has-children ul.dropdown-menu').hide();
4812							else {
4813								if($('body').width() < 768) $('#tpl-menu li.dropdown ul.dropdown-menu').hide();
4814							}
4815						}
4816
4817						if(menuVer06) {
4818							$('.el-menu .cl-moption-row').removeClass('active');
4819							if($(this).is(':not([attr-bookmark])')) {
4820								$(this).closest('.cl-moption-row').addClass('active');
4821								if($(this).closest('.cl-moption-row[data-parent]').length > 0) $(this).closest('.cl-moption-col').find('.cl-moption-row:not([data-parent])').addClass('active');
4822							}
4823						}
4824					}
4825				}
4826
4827				var loc = $(this).attr('href');
4828				var uri = (b.PUBLISH) ? loc : loc.replace('/render/','');
4829				var bookmark = $(this).attr('attr-bookmark');
4830				if(typeof bookmark !='undefined' && bookmark) return false;
4831
4832				var blank = $(this).attr('target');
4833				if(typeof blank != 'undefined' && (blank == '_blank' || blank == 'blank')) {
4834					window.open(loc);
4835					e.stopPropagation();
4836					return false;
4837				}
4838
4839				if(loc.match('^(mailto:|tel:|sms:|callto:|facetime:|skype:|sip:)')) {
4840					window.location.href = loc;
4841					return false;
4842				}
4843				if (moveRenderMenuLinkByClick(this)) {
4844					e.stopImmediatePropagation();
4845					return false;
4846				}
4847
4848				if(b.ONE!='1') {
4849					if(loc == 'javascript:;') return false;
4850
4851					if(uri == '/render' || uri == '/') {
4852						uri = b.MENULINK[0];
4853						$('body,html').animate({scrollTop: 0}, 900,'easeInOutQuart'); 
4854					}
4855
4856					if(loc.match(/\@/g) === null && loc.match(/\//g) === null || loc.match(/\?clgc\=/g) !== null) {
4857						window.location.href = loc;
4858						return false;
4859					}
4860					var url = new getLocation(loc);
4861					golink(_this,url);
4862					// _this.history.pushState(null,b.TITLE,(b.PUBLISH) ? "/" + uri : "/render/" + uri);
4863				} else {
4864					if(loc == 'javascript:;') loc = '#';
4865
4866					var hash = '';
4867					if(_this.b.PUBLISH) {
4868						if(loc.indexOf('/index/view/') > -1 && b.ONE) ;
4869						else loc = loc.replace('/index','');
4870					} else {
4871						if(loc.indexOf('/index/view/') > -1 && b.ONE) ;
4872						else loc = loc.replace('/render/index','');
4873					}
4874					hash = loc;
4875
4876					var fstr = loc.charAt(0);
4877					var pathname = window.location.pathname;
4878					switch(fstr) {
4879						case '#':
4880							if(_this.b.PAGE == 'index') {
4881								if(pathname.charAt(1) == '_' && pathname.match(/^\/\_lang\//gi) === null) {
4882									loc = (_this.b.PUBLISH) ? '/'+loc : '/render/'+loc;	
4883									window.location.href = loc;
4884								} else {
4885									if($(this).hasClass('mini-home')) {
4886										$('body,html').animate({scrollTop: 0}, 900,'easeInOutQuart'); 
4887										history.pushState('', '', hash);
4888										return false;
4889									}
4890									var urlType = (b.PUBLISH) ? '/index' : '/render';
4891									_this.history.pushState(null,b.TITLE,urlType + hash);
4892								}
4893							} else {
4894								loc = (_this.b.PUBLISH) ? '/index' : '/render/index';
4895								_this.history.pushState(null,b.TITLE,loc);
4896								history.pushState('', '', loc + hash);
4897							}
4898							break;
4899						case '@':
4900
4901							break;
4902						case '/':
4903							if(loc == '/render' || loc == '/') {
4904								loc = (_this.b.PUBLISH) ? '/index' : '/render/index';	
4905								$('body,html').animate({scrollTop: 0}, 900,'easeInOutQuart'); 
4906							}
4907							
4908							var url = new getLocation(loc);
4909							golink(_this,url);
4910							break;
4911						default:
4912							// var url = new getLocation(loc);
4913							// golink(_this,url);
4914							window.location.href = loc;
4915							break;
4916					}
4917	
4918					// window.location.href = loc;
4919				}
4920			}
4921		});
4922
4923		// [oldver Menu nav link] Click (onepage)
4924		$(`.nav li a[href*=#]:not([href="javascript:;"]), 
4925			.cl-moption > .cl-moption-col > .cl-moption-row > a[href*=#]:not([href="javascript:;"])
4926		`).live({
4927		    click : function(e) {
4928				if(typeof e.target.className == 'string' && e.target.className.indexOf('fa') > -1 && $(this).closest('header').hasClass('navbar-simple')) {
4929					e.preventDefault();
4930					return false;
4931				}
4932		        menuClickMove = true;
4933
4934		        var link = $(this).attr('href').replace('#','');
4935		        if(link.substring(0,1) == '/') link = link.substring(1,link.length);
4936		        if(b.MENULINK.indexOf(link) > -1) moveLinkPage(link);
4937		    }
4938		});
4939
4940		$('.navbar-simple .nav li a .fa').live('click', function(e) {
4941			if($(this).closest('header').hasClass('navbar-simple')) {
4942				$(this).closest('a').next('ul.dropdown-menu').slideToggle(200).closest('li').toggleClass('open').siblings().removeClass('open').find('ul.dropdown-menu').slideUp(200);
4943				e.preventDefault();
4944				return false;
4945			} 
4946		});
4947
4948		$('.navbar-simple .nav li a.dropdown-toggle[href="javascript:;"]').live('click', function(e) {
4949			e.preventDefault();
4950			if($('body').width() < 768) $(this).find('.fa').click();
4951			return false;
4952		});
4953
4954		$('body').on('click', '.micon', function(e) { $('#goto-top').removeClass('show'); });
4955
4956		$('body').on('touchstart.dropdown.data-api, click','header .siteUM-dmenu-wrap, header .siteLANG-dmenu-wrap', function(e) {
4957			if(e.target.className.indexOf('siteUM-dmenu-wrap') > -1 || e.target.className.indexOf('siteLANG-dmenu-wrap') > -1) {
4958				if($(this).hasClass('open')) {
4959					$(this).removeClass('open');
4960					$('#goto-top').addClass('show');
4961				}
4962			} 
4963		});
4964
4965		$('body').on('touchstart.dropdown.data-api, click', 'header.navbar-simple .navbar-collapse.in', function(e) {
4966			if(e.target.className.indexOf('navbar-collapse') > -1) {
4967				$('.navbar-toggle').click();
4968			}
4969		});
4970
4971
4972		$('.fr-custom-button[data-external-link]:not([data-external-link=""]), .fr-fic[data-external-link]:not([data-external-link=""])').live({
4973			click: function() {
4974				var link = $(this).attr('data-external-link');
4975				if($(this).attr('target') != '_blank') {
4976					location.href = link;
4977				} else {
4978					window.open(link);
4979				}
4980			}
4981		});
4982
4983		$('[data-type="gallery"] [data-loop="true"] > .grid').live({
4984			touchstart: function() {
4985				galleryStartHover();
4986			},
4987			touchend: function() {
4988				galleryCloseHover();
4989			},
4990			click: function() {
4991				galleryMovelink();
4992			}
4993		});
4994
4995		$(document).on('click','.cl-gtoolbar .cl-gcate-item > a, .cl-gtoolbar .cl-gsort-item > a', function(e) {
4996			var $clickTarget = $(this);
4997			var $clickItem = $clickTarget.closest('.cl-gcate-item, .cl-gsort-item');
4998			var $clickList = $clickTarget.closest('.cl-gcate-list, .cl-gsort-list');
4999			var $clickNav = $clickTarget.closest('.cl-gcate, .cl-gsort');
5000			var $clickGToolbar = $clickTarget.closest('.cl-gtoolbar');
5001			var $clickBlock = ($clickGToolbar.closest('.elem').length > 0) ? $clickGToolbar.closest('.elem').find('.element[data-type="gallery"]') : $clickGToolbar.closest('.element[data-type="gallery"]');
5002
5003			var isCategory = $clickNav.is('.cl-gcate');
5004			var isSort = $clickNav.is('.cl-gsort');
5005
5006			if ($clickItem.hasClass('active')) return;
5007
5008			if(isCategory) {
5009				if($clickNav.hasClass('empty')) {
5010					$clickTarget.blur();
5011					return false;
5012				}
5013
5014				if($clickItem.hasClass('total')) {
5015					return false;
5016				}
5017			}
5018
5019			$clickItem.addClass('active').siblings().removeClass('active');
5020			if(isSort) {
5021				var click_label = $clickTarget.text().trim();
5022				$clickGToolbar.find('.cl-gsort-active').html(click_label);
5023				$clickNav.removeClass('open');
5024			}
5025
5026			var pid = $clickBlock.attr('data-id');
5027			var idx = $clickTarget.attr('data-idx');
5028			var orderby = $clickGToolbar.find('.cl-gsort-item.active > a').attr('data-orderby') || 'recent';
5029			var sfl = 'category';
5030			var stx = $clickGToolbar.find('.cl-gcate-item.active > a').not('[data-idx="0"]').text() || '';
5031
5032			if (pid == 'all_products') {
5033				sfl = 'orderby';
5034				stx = $(this).attr('data-orderby');
5035				orderby = stx;
5036			}
5037
5038			$('#el-empty').empty();
5039			$('#el-empty').after('<div class="gallery-empty"></div>');
5040
5041			setTimeout(function() {
5042				goToElement($clickBlock);
5043			}, 0);
5044
5045			var val = _this.galleryEL[pid];
5046			var tag = htmlspecialchars_decode(val.eltag,'ENT_QUOTES');
5047			var elsettings = (typeof val.elsettings != 'undefined' && val.elsettings) ? $.parseJSON(val.elsettings) : {};
5048			var block_lang = ($(tag).attr('data-blocklang')) ? $(tag).attr('data-blocklang') : LANG;
5049			var checkGalleryListSample = false;
5050			var checkGalleryListEmpty = true;
5051
5052			$('#el-empty').append($(tag));
5053			$('#el-empty').find('[data-loop="true"]').html('');
5054
5055			var nodes = $(tag).find('[data-loop="true"]').children('.grid');
5056			initGalleryField(nodes);
5057	
5058			var g_number = $(tag).find("[data-loop='true']").data('gallery-no');
5059			var view = $(tag).find('[data-loop="true"]').data('view');
5060			var p = $('#el-empty').children();
5061			var i = [];
5062			var total = 0;
5063			var display = 0;
5064
5065			var checkLoadmoreInLoop = ($(tag).find('[data-loop="true"] .loadmore-wrap').length) ? true : false;
5066			var glm = $(tag).find('.loadmore-wrap');
5067
5068			if(typeof view == 'undefined') view = 10;
5069			var cookie_page = 1;
5070			var cookie_view = view;
5071			var cookie_gallery_category = (typeof stx != 'undefined') ? stx : '';
5072			var is_gc_cookie = (typeof $.cookie('gallery-category-'+val.seq) != 'undefined' && $.cookie('gallery-category-'+val.seq).length > 0) ? true : false;
5073			var cookie_gallery_orderby = (typeof orderby != 'undefined')? orderby : 'recent';
5074
5075			// $.cookie('gallery',val.seq, { path: '/', expires: 12 * 60 * 60 * 1000 });
5076			// $.cookie('loadmore-' + val.seq, cookie_page, { path: '/', expires: 12 * 60 * 60 * 1000 });
5077			$.cookie('gallery-page-' + val.seq, cookie_page, { path : '/', expires: 12 * 60 * 60 * 1000 });
5078			$.cookie('gallery-category-' + val.seq, cookie_gallery_category, { path : '/', expires: 12 * 60 * 60 * 1000 });
5079			$.cookie('gallery-orderby-' + val.seq, cookie_gallery_orderby, { path: '/', expires: 12 * 60 * 60 * 1000 });
5080			$.removeCookie('loadmore-' + val.seq, { path : '/' });
5081			$.removeCookie('gallery', { path : '/' });
5082
5083			$('.galleryPL'+val.seq).find('[data-loop="true"]').empty();
5084
5085			var checkGallerySVG = ($(tag).find('.gimg-svg-wrap').length > 0) ? true : false;
5086			var checkGFrameTitleOFF = (val.mode == 'gallery' && (typeof elsettings.gframe_title_visible != 'undefined' && elsettings.gframe_title_visible == 'OFF')) ? true : false;
5087
5088			var checkUseComment = checkUseCommentFunc(val.mode, val.eltag);
5089			var checkUseLike = checkUseLikeFunc(val.mode, val.eltag);
5090
5091			$.ajax({
5092				url: '/template/gallery/list/pid/' + val.seq + '/sid/' + b.SID + '/spage/' + b.PAGE + '/view/' + cookie_view + '/publish/' + b.PUBLISH + param,
5093				data: { g_mode: val.mode, visible: true, sfl: sfl, stx: stx, orderby: cookie_gallery_orderby },
5094				dataType: 'json',
5095				type: 'POST',
5096				async: false,
5097				cache: false,
5098				success: function (data) {
5099					$.each(data.list, function (idx, value) {
5100						i.push(value);
5101					});
5102
5103					total = (typeof data.total.list_total != 'undefined') ? data.total.list_total : data.total;
5104					display = data.list.length;
5105
5106					if( total > 0 ) checkGalleryListEmpty = false;
5107					if( i.length>0 || (i.length==0 && is_gc_cookie) ) {
5108						var loop_count = nodes.length, item_index = 0;
5109						var elem = [];
5110						$.each(data.list,function(index,v) {
5111							loop_pos = index%loop_count;
5112							c = nodes[loop_pos];
5113							var isTitle = (v.title.length > 0) ? true:false;
5114
5115							$(c).find('.non_text').removeClass('non_text');
5116							if(val.mode != 'shopping') {
5117								if(v.title.length==0) $(c).find('.figure.title').removeClass('non_text').addClass('non_text');
5118								if(v.caption.length==0) $(c).find('.figure.caption').removeClass('non_text').addClass('non_text');
5119							}
5120
5121							v.title = (v.title.length>0) ? v.title : $.lang[block_lang]['editor.block.gallery.sample.title'];
5122							v.caption = (v.caption.length>0) ? v.caption : $.lang[block_lang]['editor.block.gallery.sample.caption'];
5123
5124							$(c).addClass('gallery-item').attr('data-index',index).attr('data-seq',v.seq);
5125
5126							var vgsettings = (typeof v.gsettings != 'undefined' && v.gsettings) ? $.parseJSON(v.gsettings) : {},
5127								img_path = (typeof vgsettings['storage'] != 'undefined') ? vgsettings['storage'] : _this.b.RESOURCE + '/' + _this.b.SID + '/',
5128								img_original = (typeof vgsettings['storage'] != 'undefined') ? img_path + '1920/' : img_path;
5129
5130							var folder = (val.folder == 0) ? '' : val.folder + '/',
5131								src = getServeImage(v.image,val.folder,img_path),
5132								src_s0 = getServeImage(v.image,'0',img_path);
5133							if($(c).find('img').length > 0) $(c).find('img').attr('src',src);
5134							ensureGalleryResponsiveImageClass($(c));
5135							if($(c).find('.g-img').length > 0) $(c).find('.g-img').css('background-image', 'url('+src+')');
5136							if(checkGallerySVG) {
5137								var gimgSVG = $(c).find('.gimg-svg-wrap svg');
5138								gimgSVG.find('pattern').attr('id','gimgSvg_'+val.elname+'_'+index);
5139								gimgSVG.find('image').attr('xlink:href', src);
5140								gimgSVG.find('polygon, path').attr('fill', 'url(#gimgSvg_'+val.elname+'_'+index+')');
5141							}
5142							
5143							var glink = (typeof vgsettings['glink'] != 'undefined' && vgsettings['glink']) ? vgsettings['glink'] : '',
5144								glink_target = (typeof vgsettings['glink_target'] != 'undefined' && vgsettings['glink_target']) ? vgsettings['glink_target'] : '';
5145
5146							if(glink) {
5147								if(glink.match(/^\@/g) !== null) {															// link-type: link-bookmark ==> a[attr-bookmark]
5148									var bookmark_seq = glink.replace(/^\@/g,'');
5149									if(typeof _this.b.SETTINGS.blockBookmarkList == 'undefined' || typeof _this.b.SETTINGS.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
5150										glink = '';
5151										glink_target = '';
5152									}
5153								} else if(glink.match(/^flink\@[0-9]/gi) !== null) {										// link-type: link-file     ==> a[attr-flink]
5154									glink_target = '';
5155									} else if(isRenderMenuPageLink(glink, _this.b.MENULIST)) {	// link-type: link-menu     ==> a[data-user-link]
5156								} else {																					// link-type: link-out      ==> a[attr-link]
5157									if(checkBase64Encode(glink)) glink = Base64.decode(glink);
5158								}
5159							}
5160
5161							$(c).find('a').removeAttr('data-gallery').removeAttr('data-user-link').removeAttr('attr-bookmark').removeAttr('attr-link').removeAttr('attr-flink');
5162							var gallery_page_chmod = elsettings && elsettings.gallery_page_chmod || null;
5163							var umgrade = property && property.UMGRADE ? (property.UMGRADE.seq || property.UMGRADE.grade_id || null) : null;
5164							if (typeof gallery_page_chmod === 'string') {
5165								try { gallery_page_chmod = JSON.parse(gallery_page_chmod); }
5166								catch (e) { gallery_page_chmod = gallery_page_chmod ? gallery_page_chmod.split(',') : []; }
5167							}
5168							gallery_page_chmod = $.isArray(gallery_page_chmod) ? $.map(gallery_page_chmod, function(v) { return String(v); }) : [];
5169							umgrade = (umgrade !== null && typeof umgrade != 'undefined') ? String(umgrade) : null;
5170							$(c).removeClass('noneShoppingGrade').removeAttr('data-shopping-grade-msg');
5171							if (isShoppingGradePriceHidden(v) && property['SITEUM'] >= 1) {
5172								$(c).addClass('gallery-item').addClass('nonePrice');
5173								$(c).find('a').attr('href', '#');
5174							} else {
5175								if(isShoppingGradeBlocked(v, elsettings, property)) {
5176									$(c).addClass('gallery-item').addClass('noneShoppingGrade');
5177									$(c).attr('data-shopping-grade-msg', getShoppingGradeBlockedMessage(v));
5178									$(c).find('a').attr('href', '#');
5179								} else if(glink) {
5180									var glink_val = makeLinkUrl(glink, b.ONE, b.VIEW);
5181									$(c).find('a').attr('href',glink_val);
5182
5183									if(glink.match(/^\@/g)) {
5184										$(c).find('a').attr('attr-bookmark',glink.replace(/^\@/g,''));
5185									} else if(glink.match(/^flink\@[0-9]/g) !== null) {
5186										$(c).find('a').attr('attr-flink',glink.replace(/^flink\@/g,''));
5187									// IE ERROR_includes__H.20210603
5188									// } else if(_this.b.MENULIST.includes(glink.replace(/ /g,'-'))) {
5189										} else if(isRenderMenuPageLink(glink, _this.b.MENULIST)) {
5190										$(c).find('a').attr('data-user-link',glink_val);
5191									} else {
5192										$(c).find('a').attr('attr-link',glink);
5193									}
5194								} else {
5195									if (val.mode == 'gallery') {
5196										src_s0 = src_s0 + '?gpos='+v.pos;
5197
5198										$(c).find('a').attr('href', src_s0);
5199										$(c).find('a').attr('data-gallery', '#gframe-' + val.seq);
5200									} else {
5201										if(val.seq == 'all_products') {
5202											$(c).find('a').attr('href', v.product_url);
5203										} else {
5204											if(_this.b.LUX) $(c).find('a').attr('href', ((_this.b.URL=='/') ? '' : _this.b.URL) + '/_product/' + v.seq);
5205											else $(c).find('a').attr('href', ((_this.b.URL=='/') ? '' : _this.b.URL) + '/' + _this.b.PAGE + '/view/' + v.seq);
5206			
5207											// $(c).find('a').attr('href', ((URI=='/') ? '' : URI) + '/' + b.PAGE + '/view/' + v.seq);
5208										}
5209									}
5210								}
5211							}
5212
5213							if(glink_target == '_blank') $(c).find('a').attr('target','_blank');
5214							else $(c).find('a').removeAttr('target');
5215
5216							if(checkGFrameTitleOFF || !isTitle) $(c).find('a').attr('data-title', '');
5217							else $(c).find('a').attr('data-title', v.title);
5218
5219							// caption
5220							var ftitle = $(c).find('h5.figure'),
5221								fcaption = $(c).find('p.figure').not('.comment'),
5222								fdatetime = $(c).find('.figure.datetime'),
5223								fhashtag = $(c).find('.figure.hashtag'),
5224								fbrand = $(c).find('.figure.brand'),
5225								fprice = $(c).find('.figure.price'),
5226								freview = $(c).find('.figure.review'),
5227								fcomment = $(c).find('.figure.comment'),
5228								flike = $(c).find('.figure.like'),
5229								fbasket = $(c).find('.figure.basket');
5230
5231							$(c).find('figcaption').removeClass('hide');
5232							if (v.title || v.caption) {
5233								var gallery_caption = v.caption;
5234								gallery_caption = gallery_caption.replace(/\n/g,'<br />');
5235
5236								ftitle.html(v.title);
5237								fcaption.html(gallery_caption);
5238								if(fdatetime.length > 0) fdatetime.text(v.datetime);
5239								if(fhashtag.length > 0) fhashtag.text(v.hashtag);
5240							}
5241
5242							if(g_number) {
5243								var g_index = String(index + 1),
5244									g_num = g_index.padStart(g_number, '0');
5245								$(c).find('.figure.number').text(g_num);
5246							}
5247
5248							if(fbrand.length > 0) {
5249								var fbrand_name = (typeof v.brand_name != 'undefined' && v.brand_name) ? v.brand_name : '';
5250								fbrand.html(v.brand_name);
5251							}
5252
5253							if(val.mode == 'shopping' || val.seq == 'all_products') {
5254								fcomment.addClass('hide');
5255								flike.addClass('hide');
5256								v.price = typeof v.price != 'undefined' ? parseFloat(v.price) : 0;
5257								v.sale = typeof v.sale != 'undefined' ? parseFloat(v.sale) : 0;
5258								var productGradeOnOff = getShoppingGradeProductGradeOnOff(v);
5259								$(c).attr('data-editor-grade-price-enabled', productGradeOnOff).attr('data-config-grade-price-enabled', productGradeOnOff);
5260								var checkPriceHidden = isShoppingGradePriceHidden(v),
5261									base_gallery_price = (v.price && !checkPriceHidden) ? v.price : 0,
5262									base_gallery_sale_price = (typeof v.sale != 'undefined' && v.sale > 0 && v.sale > v.price && !checkPriceHidden) ? v.sale : 0,
5263									gallery_price = base_gallery_price,
5264									gallery_sale_price = base_gallery_sale_price,
5265									gallery_sale_per = (typeof v.sale_per != 'undefined' && v.sale_per && !checkPriceHidden) ? v.sale_per+'%' : '',
5266									grade_price_display = elsettings.grade_price_display == 'ON',
5267									grade_discount_grade = getShoppingGradePreviewDiscountGrade(data.grade),
5268									grade_discount_applied = false,
5269									grade_gallery_price = 0,
5270									product_soldout = '품절',
5271									product_no_sale = (typeof elsettings.sh_soldout == 'string') ? elsettings.sh_soldout : '구매불가',
5272									product_status = '';
5273								if (
5274									!checkPriceHidden &&
5275									isShoppingGradeProductGradePriceEnabled(v)
5276								) {
5277									grade_gallery_price = calcShoppingGradeDisplayPrice(base_gallery_price, grade_discount_grade);
5278									grade_discount_applied = grade_gallery_price !== null;
5279								}
5280								if(v.status == 'off' && !checkPriceHidden) {
5281									product_status = '<span class="cl-sh-soldout">' + product_no_sale + '</span>';
5282								} else if(v.quantity_on == 'on' && v.quantity < 1 && !checkPriceHidden) {
5283									product_status = '<span class="cl-sh-soldout">' + product_soldout + '</span>';
5284								}
5285								$(c).find('.cl-sh-soldout').remove();
5286								if(product_status != '') $(c).attr('data-soldout',true);
5287								else $(c).removeAttr('data-soldout');
5288
5289								$(c).find('.product-badge').remove();
5290								product_status += drawBadgeList(v.use_badge, data.badge_settings);
5291
5292								$(c).find('.cl-sh-limit').remove();
5293								if(v.status == 'lim') {
5294									if(v.sale_now == false) {
5295										var product_limit = '<p class="cl-sh-limit">상품 구매 가능 기간이 아닙니다.</p>';
5296										if(freview.length > 0) {
5297											freview.after(product_limit);
5298										} else {
5299											$(c).find('figcaption:not(.top) .figure:last-child').after(product_limit);
5300										}
5301									}
5302								}
5303
5304								// $(c).find('a').removeAttr('data-gallery').removeAttr('data-user-link').removeAttr('attr-bookmark').removeAttr('attr-link').removeAttr('attr-flink');
5305								// if (typeof v.price_hidden != 'undefined' && v.price_hidden == 'ON' && property['SITEUM'] >= 1) {
5306								// 	console.log(222);
5307								// 	$(c).addClass('gallery-item').addClass('nonePrice');
5308								// 	$(c).find('a').attr('href', '#');
5309								// } else {
5310								// 	console.log(22222);
5311								// 	if(glink) {
5312								// 		var glink_val = makeLinkUrl(glink, b.ONE, b.VIEW);
5313								// 		$(c).find('a').attr('href',glink_val);
5314
5315								if($(c).find('ul.figure.price').length > 0) {
5316									// var price_off = (v.sale_price > 0 && v.sale_price > v.price) ? 100 - Math.floor((v.price / v.sale_price) * 100) : 0,
5317									// 	off_str = (price_off > 0) ? price_off + '% ' : ''
5318									var off_str = (v.sale_rate > 0) ? v.sale_rate + '% ' : '';
5319									if(!_this.b.LUX) off_str = gallery_sale_per;
5320									if(!off_str && gallery_sale_price > 0 && gallery_price > 0 && gallery_price < gallery_sale_price) {
5321										var price_off = Math.round(((gallery_sale_price - gallery_price) / gallery_sale_price) * 100);
5322										off_str = (price_off > 0) ? price_off + '% ' : '';
5323									}
5324									//Ver2
5325									if(!checkPriceHidden) {
5326										var $priceWrap = $(c).find('ul.figure.price'),
5327											$priceVal = $priceWrap.find('.price-val'),
5328											$priceSale = $priceWrap.find('.price-sale'),
5329											$priceSalePer = $priceWrap.find('.price-sale-per');
5330										$priceWrap.find('.sp-price, .grade-discount-price').remove();
5331										if($priceSale.length > 0 && $priceSalePer.length == 0) {
5332											$priceSale.after('<li class="price-sale-per hide"></li>');
5333											$priceSalePer = $priceWrap.find('.price-sale-per');
5334										}
5335										$priceWrap.css({display:'', flexDirection:'', alignItems:''});
5336										$priceVal.css({order:'', display:''});
5337										$priceSale.css({order:'', display:'', marginRight:''});
5338										$priceSalePer.css({order:'', display:'', marginLeft:'', marginTop:''});
5339											$priceVal.html('₩' + gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,','));
5340										$priceVal.removeClass('hide');
5341
5342										if(gallery_sale_price > 0 && gallery_price  < gallery_sale_price) {
5343											$priceSale.html('₩' + gallery_sale_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,','));
5344												$priceSalePer.html(off_str);
5345											$priceSale.removeClass('hide');
5346												$priceSalePer.removeClass('hide');
5347											if(!grade_discount_applied && _this.b.LUX && (v.hashtag).indexOf('특가세일') > -1 && $(c).find('ul.figure.price .sp-price').length == 0) {
5348												$(c).find('ul.figure.price .price-sale').after('<li class="sp-price">특가세일</li>');
5349											}
5350										} else {
5351											$priceSale.addClass('hide').html('');
5352											$priceSalePer.addClass('hide').html('');
5353
5354										}
5355
5356										if(grade_price_display && grade_discount_applied) {
5357											$priceWrap.append('<li class="grade-discount-price"><span class="grade-discount-price-value">₩' + grade_gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,',') + '</span><span class="grade-discount-price-label">나의 할인가</span></li>');
5358										}
5359
5360										$(c).find('ul.figure.price .price-unit-pricing').remove();
5361										if(v.product_unit_str) {
5362											$(c).find('ul.figure.price').append(`<li class="price-unit-pricing">${v.product_unit_str}</li>`); // 단위당 가격
5363										}
5364									} else {
5365										$(c).find('ul.figure.price .price-val').html('₩0');
5366										$(c).find('ul.figure.price .price-val').addClass('hide');
5367									}
5368									if(val.seq == 'all_products' && checkPriceHidden) $(c).find('ul.figure.price').html('');
5369									if(product_status) $(c).find('ul.figure.price').append('<li>'+product_status+'</li>');
5370
5371									var badge_size = getBadgeSize(data.badge_settings);
5372									$(c).find('.cl-sh-soldout').removeClass('badge-small badge-medium badge-large');
5373									$(c).find('.cl-sh-limit').removeClass('badge-small badge-medium badge-large');
5374									if(badge_size) {
5375										$(c).find('.cl-sh-soldout').addClass(badge_size);
5376										$(c).find('.cl-sh-limit').addClass(badge_size);
5377									}
5378								} else {
5379									//Ver1
5380									if(fprice.length == 0) fprice = fcaption;
5381									
5382									if(checkPriceHidden) fprice.html('');
5383									else fprice.html('<span class="figure-krw">₩</span>' + gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,',') + product_status);
5384								}
5385
5386								if($(c).find('ul.figure.review').length > 0) {
5387									var gallery_review = (v.review_onoff && v.review_cnt) ? v.review_cnt : 0;
5388									if(gallery_review > 0) {
5389										$(c).find('ul.figure.review, ul.figure.review li').removeClass('hide');
5390										$(c).find('ul.figure.review .figure-review-cnt').html(gallery_review);
5391										$(c).find('ul.figure.review .figure-review-score').html(v.review_score);
5392									} else {
5393										$(c).find('ul.figure.review, ul.figure.review li').addClass('hide');
5394										$(c).find('ul.figure.review .figure-review-cnt, ul.figure.review .figure-review-score').html('');
5395									}
5396								}
5397
5398								if(fbasket.length > 0) {
5399									var checkOldBlock = ($(c).find('.figure.basket[data-oldver="true"]').length > 0) ? true : false,
5400										checkOldverBasket = (typeof elsettings.field_oldver != 'undefined' && elsettings.field_oldver && elsettings.field_oldver.indexOf('basket') > -1) ? true : false,
5401										checkDisabledBasket = (typeof elsettings.field_disable != 'undefined' && elsettings.field_disable && elsettings.field_disable.indexOf('basket') > -1) ? true : false;
5402									if(v.basket_off || v.shopping_grade_hidden == 'ON') fbasket.addClass('cannotby hide');
5403									else if(val.seq == 'all_products') fbasket.removeClass('hide');
5404									else if(checkDisabledBasket || (!checkDisabledBasket && checkOldBlock && !checkOldverBasket)) fbasket.addClass('hide');
5405									else if(property.VALIDTYPE != 'SM') fbasket.addClass('hide');
5406									else fbasket.removeClass('hide');
5407								}
5408
5409							} else {
5410								fbrand.addClass('hide');
5411								fprice.addClass('hide');
5412								freview.addClass('hide');
5413								fbasket.addClass('hide');
5414
5415								if ( checkUseComment 
5416									&& elsettings.comment_display == 'ON'
5417									&& !(elsettings.field_disable !== undefined && elsettings.field_disable.indexOf('comment') > -1)
5418									&& fcomment.length > 0
5419									&& (typeof v.comment_cnt != 'undefined' && v.comment_cnt > 0)
5420								) {
5421									fcomment.removeClass('hide');
5422									fcomment.find('.figure-comment-cnt').html(v.comment_cnt);
5423								} else {
5424									fcomment.addClass('hide');
5425									fcomment.find('.figure-comment-cnt').empty();
5426								}
5427	
5428								if ( checkUseLike 
5429									&& (elsettings.like_display !== undefined && elsettings.like_display != 'N')
5430									&& !(elsettings.field_disable !== undefined && elsettings.field_disable.indexOf('like') > -1)
5431									&& flike.length > 0
5432								) {
5433									flike.removeClass('hide').find('.figure-like-cnt').html(0);
5434									if(v.like !== undefined) {
5435										flike.find('.figure-like-cnt').html(v.like.cnt);
5436										if (v.like.own && v.like.cnt > 0) flike.attr('data-like', v.seq).addClass('active');
5437									}
5438								} else {
5439									flike.addClass('hide');
5440								}
5441							}
5442							
5443							if(checkUseLike == false) flike.html('');
5444
5445							if(val.mode == 'gallery') {
5446								if(index < cookie_view) {
5447									$(p).find('[data-loop="true"]').append($(c)[0].outerHTML);
5448								} else {
5449									$(c).find('figure').remove();
5450									$('.galleryPL'+val.seq).find('[data-loop="true"]').append($(c)[0].outerHTML);
5451								}
5452								if (total == 2) {
5453									$(c).find('figure').remove();
5454									$('.gallery-empty').append($(c)[0].outerHTML);
5455								}
5456							} else {
5457								$(p).find('[data-loop="true"]').append($(c)[0].outerHTML);
5458							}
5459						});
5460					} else {
5461						if(idx == '0') {
5462							checkGalleryListSample = true;
5463							nodes.find('a')
5464								.addClass('emptyGalleryItem')
5465								.attr('href', '/config/page/' + b.PAGE + '/view/template')
5466								.removeAttr('data-gallery')
5467								.removeAttr('data-user-link')
5468								.removeAttr('attr-bookmark')
5469								.removeAttr('attr-flink')
5470								.removeAttr('attr-link')
5471								.find('img')
5472								.attr('data-index',0);
5473							$(p).find('[data-loop="true"]').append(nodes);
5474						}
5475
5476						$.cookie('gallery-category-'+val.seq,'',{ path: '/', expires: 12 * 60 * 60 * 1000 });
5477						$.cookie('gallery-orderby-' + val.seq, '', { path: '/', expires: 12 * 60 * 60 * 1000 });
5478					}
5479					if(checkLoadmoreInLoop) $(p).find('[data-loop="true"]').append(glm);
5480					tag = $(p)[0].outerHTML;
5481
5482					if (val.mode == 'gallery' && total == 2) {
5483						$.each($('.gallery-empty').find('.gallery-item'), function(i,v) {
5484							var gallerySeq = $(v).attr('data-seq');
5485							if($('.galleryPL'+val.seq).find('.gallery-item[data-seq='+gallerySeq+']').length == 0) $('.galleryPL'+val.seq).find('[data-loop="true"]').append($(v).attr('data-index', i+2));
5486						});
5487					}
5488			
5489					if (val.mode == 'gallery' && total) tag = appendGalleryFrame($(tag), val.seq, val.type, val.elsettings);
5490					$('#el-empty').empty();
5491					$('.gallery-empty').remove();
5492				}
5493			});
5494
5495			var $tag = $(tag);
5496			var $galleryEL = $('.element[data-id="' + val.seq + '"]');
5497			var g_settings = (typeof val.elsettings != 'undefined' && val.elsettings) ? $.parseJSON(val.elsettings) : {};
5498
5499			changeBrokenImages($tag);
5500			$.each($tag.find('[data-edit="true"]'), function() {
5501				var source = $(this).html();
5502				source = source.replace(/&lt;&nbsp;/g,'&lt;').replace(/&nbsp;&gt;/g,'&gt;');
5503				$(this).html(source);
5504			});
5505
5506
5507			if(total > 0) $galleryEL.find('[data-loop="true"]').replaceWith($tag.find('[data-loop="true"]'));
5508			else $galleryEL.find('[data-loop="true"]').empty();
5509			if(checkGalleryListSample && total == 0) $gallery_items.find('.emptyGalleryItem').attr('data-gallery','');
5510			showHideGalleryField($galleryEL, g_settings);
5511			reloadBlockMasonry('init',$galleryEL);
5512
5513			var $glmBtnWrap = $galleryEL.find('.loadmore-wrap');
5514			var $glmBtn = $galleryEL.find('.loadmore-wrap .gallery-loadmore');
5515			var checkLoadmore = (total > view && total > cookie_view && !checkGalleryListEmpty) ? true : false;
5516			var glm_lang = LANG;
5517			if(typeof g_settings.loadmore_lang != 'undefined' && g_settings.loadmore_lang && $.inArray(g_settings.loadmore_lang.toLowerCase(), ['ko','en']) > -1) glm_lang = g_settings.loadmore_lang.toLowerCase();
5518			else if(typeof block_lang != 'undefined' && $.inArray(block_lang, ['ko','en']) > -1) glm_lang = block_lang;
5519			var glm_txt = $.lang[glm_lang]['config.loadmore'];
5520
5521			if($glmBtnWrap.length == 0) {
5522				// gallery loadmore btn - default (ver1)
5523				if(checkLoadmore) {
5524					var glm_class = (val.feature=='masonry') ? 'gallery-loadmore masonry-layout' : 'gallery-loadmore',
5525						glm_btn = '<div class="' + glm_class + '" data-loadmore="true" data-selector=".gallery-loadmore" data-total="' + total + '" data-id="' + val.seq + '" data-page="2" data-view="' + view + '" data-folder="' + val.folder + '" data-mode="' + val.mode + '">' + glm_txt +' &nbsp;(<span class="display">' + cookie_view + '</span> / ' + number_format(total) + ')</div>';
5526
5527					if($galleryEL.find('.gallery-loadmore').length > 0) $galleryEL.find('.gallery-loadmore').replaceWith(glm_btn);
5528					else $galleryEL.append(glm_btn);
5529				} else $galleryEL.find('.gallery-loadmore').remove();
5530
5531			} else {
5532				// gallery loadmore btn - custom (ver2)
5533				if(checkLoadmore) {
5534					if(val.feature=='masonry') $glmBtn.addClass('masonry-layout');
5535					else $glmBtn.removeClass('masonry-layout');
5536					$glmBtn.attr('data-loadmore','true').attr('data-id',val.seq).attr('data-total',total).attr('data-page',2).attr('data-view',view).attr('data-folder',val.folder).attr('data-mode',val.mode);
5537					$glmBtn.find('.label').text(glm_txt);
5538					$glmBtn.find('.display .view').text(cookie_view);
5539					$glmBtn.find('.display .total').text(total);
5540					$glmBtnWrap.removeClass('hide').fadeIn();
5541				} else {
5542					$glmBtnWrap.fadeOut().addClass('hide');
5543					$glmBtn.removeAttr('data-loadmore').removeAttr('data-id').removeAttr('data-total').removeAttr('data-page').removeAttr('data-view').removeAttr('data-folder').removeAttr('data-mode').removeClass('masonry-layout');
5544					$glmBtn.find('.label').text(glm_txt);
5545					$glmBtn.find('.display .view').text('0');
5546					$glmBtn.find('.display .total').text('0');
5547				}
5548			}
5549
5550			if($galleryEL.has('input.gjs').length) setGalleryJS('change-loop',$galleryEL);
5551
5552			if($galleryEL.find('*[data-direffect="true"]').length > 0 ) {
5553				setTimeout(function() {
5554					$galleryEL.find('.grid').each(function() {
5555						$(this).hoverdir();
5556					});
5557				}, 400);
5558			}
5559		});
5560
5561		$(':not(.review-sample-block) .review-sort-nav .toggle-dropdown').live({
5562		    click: function(e) {
5563		        $(this).closest('.review-sort-nav').toggleClass('open');
5564		    }
5565		});
5566
5567		$(':not(.review-sample-block) .review-sort-nav li a').live({
5568		    click: function() {
5569	        	if ($(this).closest('li').hasClass('active')) return;
5570
5571	        	var review_block_id = $(this).closest('.element').attr('data-id');
5572	        	var idx = $(this).attr('data-idx'),
5573		            orderby = $(this).attr('data-orderby');
5574	            $('.element[data-id="'+review_block_id+'"] .review-sort-nav li').removeClass('active');
5575	            $('.element[data-id="'+review_block_id+'"] .review-sort-nav li').eq(idx).addClass('active');
5576	            $('.element[data-id="'+review_block_id+'"] .review-sort-nav .active-sort').text($(this).text().trim());
5577	            $(this).closest('.review-sort-nav').removeClass('open');
5578
5579	        	var val = _this.galleryEL[review_block_id];
5580            	var settings = (typeof val.elsettings != 'undefined' && val.elsettings) ? $.parseJSON(val.elsettings) : {};
5581            	var gallery_data = (typeof settings.gallery_data != 'undefined' && settings.gallery_data) ? settings.gallery_data : {};
5582            	var cookie_review_orderby = (typeof orderby != 'undefined')? orderby : 'recent';
5583
5584            	$.cookie('review-orderby-' + review_block_id, cookie_review_orderby, { path: '/', expires: 12 * 60 * 60 * 1000 });
5585            	$.reviewContents.init(review_block_id, gallery_data);
5586		    }
5587		});
5588
5589		$(':not(.review-sample-block) .review-data-loadmore').live({
5590		    click: function() {
5591		    	var review_block_id = $(this).attr('data-id'),
5592					page_num = (typeof $(this).attr('data-page') != 'undefined') ? Number($(this).attr('data-page')) : 1,
5593					view = (typeof $(this).attr('data-view') != 'undefined') ? Number($(this).attr('data-view')) : 6,
5594					$review_elLoadmore = $(this),
5595					$review_el = $('.element[data-id="' + review_block_id + '"]'),
5596					$rContainer = $review_el.find('.container'),
5597					$rLoop = $review_el.find('[data-loop="true"]'),
5598		            $ro = $review_el.find('.review-sort-nav li.active a'),
5599		            orderby = ($ro.length > 0) ? $ro.attr('data-orderby') : 'recent';
5600
5601		        var val = _this.galleryEL[review_block_id];
5602            	var settings = (typeof val.elsettings != 'undefined' && val.elsettings) ? $.parseJSON(val.elsettings) : {};
5603            	var gallery_data = (typeof settings.gallery_data != 'undefined' && settings.gallery_data) ? settings.gallery_data : {};
5604            	// var cookie_review_orderby = (typeof orderby != 'undefined')? orderby : 'recent';
5605
5606            	$.cookie('review-orderby-' + review_block_id, orderby, { path: '/', expires: 12 * 60 * 60 * 1000 });
5607            	$.reviewContents.update(review_block_id, gallery_data, orderby, page_num);
5608		    }
5609		});
5610
5611		// menu ver3 : fheader - #mobile-nav show/hide function
5612		$(document).on('click', 'ul li.siteSEARCH > a.psearch-btn, ul li.siteSEARCH .psearch-overlay.open, ul li.siteSEARCH .psearch-input', function(e) {
5613			e.preventDefault();
5614			if($(this).is('a.psearch-btn') && PAGE_MODE == 'r') {
5615				$(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['psearch.no-support.render'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70');
5616				return false;
5617			}
5618
5619			var taret_nav = $('.el-menu header');
5620			if(window.innerWidth <= 768) taret_nav = $('#mobile-nav');
5621			var check_psearch_area = (taret_nav.find('.psearch-wrap').is(e.target) || taret_nav.find('.psearch-wrap').has(e.target).length > 0) ? true : false;
5622	
5623			if(!check_psearch_area) {
5624				taret_nav.find('.psearch-overlay').toggleClass('open');
5625				setTimeout(function() {
5626					$.psearch.showSiteProjectSEARCH(false);
5627					taret_nav.find('.psearch-overlay').find('input.psearch-input').focus();
5628				},300);
5629			}
5630			return false;
5631		});
5632		$(document).on('click', '#fixed-menu li.siteCART > a[href="javascript:;"], #fixed-menu-sub li.siteCART > a[href="javascript:;"]', function(e) {
5633			e.preventDefault();
5634			$(this).showModalFlat('INFORMATION',$.lang[LANG]['menu.cart.no-support.render'],true,false,'','ok');
5635			return false;
5636		});
5637		$(document).on('click', '.siteLANG ul a, .siteLANG-dmenu-wrap ul li a', function(e) {
5638			if(LANGLINK) return;
5639			e.preventDefault();
5640			var sid = (typeof SID != 'undefined' && SID) ? SID : property.SID;
5641			var slang_code = $(this).attr('data-code');
5642			var slang_str = $(this).text().trim();
5643
5644			changeLanguage(slang_code);
5645		});
5646		$(document).on('click', '#mobile-nav .login-content:not(.siteUM)', function(e) {
5647			e.preventDefault();
5648			$('#mobile-nav #fixed-menu .siteUM a i').click();
5649			return false;
5650		});
5651		$(document).on('click', '#mobile-nav .nav li.menu-has-children > a[href="javascript:;"]', function(e) {
5652			e.preventDefault();
5653			$(this).prev('.fa').click();
5654			return false;
5655		});
5656		$(document).on('click', '#mobile-nav ul li.menu-has-children i', function(e) {
5657			if($(this).closest('li.menu-has-children').hasClass('open')) {
5658				$(this).closest('li.menu-has-children').removeClass('open');
5659				$(this).nextAll('ul').eq(0).slideToggle(200);
5660				// $(this).next().removeClass('menu-item-active');
5661				$(this).toggleClass('fa-chevron-down fa-chevron-up');
5662			} else {
5663				$(this).closest('li.menu-has-children').addClass('open').siblings('li.open').find('i').click();
5664				$(this).nextAll('ul').eq(0).slideToggle(200);
5665				// $(this).next().toggleClass('menu-item-active');
5666				$(this).toggleClass('fa-chevron-down fa-chevron-up');
5667			}
5668		});
5669		$(document).on('click', 'header.navbar-fheader .navbar-toggle', function(e) {
5670			if( window.innerWidth > 768 &&
5671				$(this).closest('header').find('.cl-menu-option').length > 0 && 
5672				$(this).closest('header').find('.cl-menu-option').is('[data-moption="ntoggle"],.nfullDrop')
5673			) {
5674				e.preventDefault();
5675				return false;
5676			}
5677
5678			if($('.dsgn-body').hasClass('mobile-nav-active')) {
5679				//close mobile menu
5680				$('header.navbar-fheader .navbar-toggle').css({'visibility':'visible'});
5681				$('.dsgn-body').removeClass('mobile-nav-active');
5682				$('#mobile-body-overly').removeClass('in');
5683				$('#mobile-nav .siteLANG.cl-fixbtn').hide();
5684			} else {
5685				//show mobile menu
5686				$('header.navbar-fheader .navbar-toggle').css({'visibility':'hidden'});
5687				$('.dsgn-body').addClass('mobile-nav-active');
5688				$('#mobile-body-overly').addClass('in');
5689				$('#mobile-nav .siteLANG.cl-fixbtn').show();
5690			}
5691		});
5692		$(document).on('click', '#mobile-nav-toggle', function(e) {
5693			$('header.navbar-fheader .navbar-toggle').click();
5694		});
5695
5696		$('header.navbar-simple .navbar-toggle').live('click',function(e) {
5697			var check = $(this).hasClass('collapsed') ? false : true;
5698			if(check) {
5699				var p_t = $('.el-menu header').height() + 'px';
5700
5701				$('.element').each(function(){ $(this).addClass('blur-filter'); });
5702				$('.el-menu').addClass('blur-filter');
5703
5704				if($('body').height() > ($('.el-menu').find('#tpl-menu').height() + 80)) $('.el-menu').find('#tpl-menu').addClass('center-position');
5705				else $('.el-menu').find('#tpl-menu').removeClass('center-position');
5706				
5707				$('.dsgn-body').bind('touchmove');
5708				$('#goto-top').removeClass('show');
5709			} else {
5710				$('.element').each(function(){ $(this).removeClass('blur-filter'); });
5711				$('.el-menu').removeClass('blur-filter');
5712		        $('.dsgn-body').unbind('touchmove');
5713				$('#goto-top').addClass('show');
5714			}
5715		});
5716
5717		$('.element[data-type="gallery"]').live({
5718			mouseenter : function() {
5719				$(this).find('[data-direffect="true"] .grid').each(function() {
5720					$(this).hoverdir();
5721				});
5722			}
5723		});	
5724
5725		$('.creatorlink-header .data-user > ul > li').live({
5726			click : function() {
5727				$(this).closest('.pull-right').toggleClass('open');
5728				if($(this).closest('.pull-right').hasClass('open')) {
5729					$('.popover').show();
5730				} else {
5731					$('.popover').hide();
5732				}
5733			}
5734		});
5735
5736		/* [Input URL link] Click ==> link-type: link-out*/
5737		$('a[href*=#][attr-link]').live({
5738			click : function(e) {
5739				if($(this).is('[attr-link=""]') 
5740					|| $(this).is('[data-imglink="true"]')
5741					|| (typeof e.target.className == 'string' && e.target.className.indexOf('fa') > -1 && $(this).closest('header').hasClass('navbar-simple'))
5742				) {
5743					e.preventDefault();
5744					return false;
5745				} 
5746
5747				$.removeCookie('gallery', { path: '/' });
5748				$.removeCookie('gallery-item', { path : '/' });
5749				$.removeCookie('forum', { path : '/' });
5750				$.removeCookie('forum-item', { path : '/' });
5751				
5752				if($(this).attr('target') != '_blank') {
5753					var link = $(this).attr('href').replace('#','');
5754					if(link.length > 0 && link != '/') {
5755						var regex = /^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/;
5756						var regex2 = /^((http(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/;
5757						var ismenulink = (b.MENULINK.indexOf(link) > -1) ? true : false;
5758						var isoutlink = (regex2.test(link) || regex.test(link)) ? true : false;
5759						if (ismenulink) {
5760							if ($('.dsgn-body').width() < 769) {
5761								setTimeout(function() {
5762									moveLinkPage(link);
5763								}, 250);
5764							} else {
5765								moveLinkPage(link);
5766							}
5767						} else if(!isoutlink && $('.' + link).length) {
5768							moveLinkPage(link, 1200, true);
5769						}
5770
5771
5772						if(b.MENULINK.indexOf(link) > -1) {
5773							if($('.dsgn-body').width() < 769) {
5774								setTimeout(function() {
5775									moveLinkPage(link);
5776								},250);
5777							} else {
5778								moveLinkPage(link);
5779							}
5780						} else if($('.' + link).length) {
5781							moveLinkPage(link,1200,true);
5782						}
5783					}
5784				}
5785		    }
5786		    
5787		});
5788
5789		/* [Menu link] Click ==> link-type: link-menu or link-inner*/
5790		$('*[data-user-link]').live('click',function(e) {
5791			if(	$.clnav.check()
5792				&& $(this).parent().hasClass('cl-nav-item')
5793				&& ($(this).closest('.clnav-nowrap-target').length > 0 || $(this).closest('.clnav-sidemobile').length > 0)
5794			) {
5795				/* .cl-nav[data-behavior="overflow-nowrap"] */
5796				if ($.clnav.d.isDrag) {
5797					e.preventDefault();
5798					e.stopImmediatePropagation();
5799					return false;
5800				}
5801			}
5802
5803			if(	$(this).is('[data-user-link=""]') 
5804				|| (typeof e.target.className == 'string' && e.target.className.indexOf('fa') > -1 && $(this).closest('header').hasClass('navbar-simple'))
5805			) {
5806				e.preventDefault();
5807				return false;
5808			}
5809
5810			var currentMenuLinkId = $(this).attr('data-user-link-id') || '';
5811			if (currentMenuLinkId) {
5812				var currentMenuMap = getRenderMenuUidMap(property.SMENU || []);
5813				var currentMenuSource = currentMenuMap[currentMenuLinkId];
5814				var currentDestination = currentMenuSource ? resolveRenderMenuDestination(property.SMENU || [], currentMenuSource) : null;
5815				if (currentDestination) {
5816					applyRenderMenuDestination($(this), currentDestination, property.ONE, property.VIEW);
5817					if (currentDestination.type != 'page') {
5818						e.preventDefault();
5819						e.stopImmediatePropagation();
5820						if (currentDestination.type == 'url') {
5821							if ($(this).attr('target') == '_blank') window.open(currentDestination.value);
5822							else location.href = currentDestination.value;
5823						} else if (currentDestination.type == 'bookmark') {
5824							moveLinkPage(currentDestination.value, 1200, true);
5825						} else if (currentDestination.type == 'file') {
5826							var $fileLink = $('<a href="javascript:;" attr-flink="' + currentDestination.value + '" style="display:none;"></a>').appendTo('body');
5827							$fileLink.trigger('click');
5828							setTimeout(function() { $fileLink.remove(); }, 0);
5829						}
5830						return false;
5831					}
5832				}
5833			}
5834
5835			var $targetEle = $(this).closest('.element[data-el]');
5836			var datatype = $targetEle.attr('data-type') ?? '';
5837			var isimglink = $targetEle && $targetEle.length && $targetEle.hasClass('imglink');
5838			var hasalink = $(this).hasClass('sha_link');
5839			var isshlink = $(this).is('[data-shlink]');
5840
5841			var userLink = ((datatype == 'showcase') && isimglink && isshlink) ? $(this).attr('data-shlink') : $(this).attr('href');
5842			if (typeof userLink == 'undefined') return false;
5843
5844			var target = '';
5845			if ((typeof $(this).attr('target') != 'undefined') 
5846				|| (typeof $(this).attr('data-blank') != 'undefined')
5847			) {
5848				if ((datatype == 'showcase') && isimglink && isshlink) {
5849					target = $(this).attr('data-blank');
5850				} else {
5851					target = $(this).attr('target');
5852				}
5853			}
5854
5855			e.preventDefault();
5856			$.removeCookie('gallery', { path: '/' });
5857			$.removeCookie('gallery-item', { path: '/' });
5858			$.removeCookie('forum', { path: '/' });
5859			$.removeCookie('forum-item', { path: '/' });
5860			if (moveRenderMenuLinkByClick(this)) {
5861				e.stopImmediatePropagation();
5862				return false;
5863			}
5864
5865			//latest block - table header click, set click table
5866			if(typeof $(this).attr('data-lt-header') != 'undefined') {
5867				var type = $(this).closest('.latest-table').attr('data-type');
5868				var pid = $(this).closest('.latest-table').attr('data-pid');
5869				var clickEL = (type == 'gallery') ? $('.gallery-item[data-seq="'+pid+'"]') : $('.element[data-id="' + pid + '"]');
5870				var checkThisPage = (b.ONE && clickEL.length > 0) ? true : false;
5871
5872				if(checkThisPage) {
5873					if(type == 'forum') {
5874						scrollToBlock('.element[data-id="' + pid + '"]', 1000);
5875						return false;
5876					} else if(type == 'gallery') {
5877						moveGallery(pid);
5878						return false;
5879					}
5880				} else {
5881					$.cookie(type+'-item',pid, { path: '/' });
5882				}
5883			} else {
5884				if (typeof $(this).attr('data-forum-type') !== 'undefined' && $(this).attr('data-forum-type') == 'qna') {
5885					var type = $(this).closest('.latest-table').attr('data-type');
5886					var pid = $(this).closest('.latest-table').attr('data-pid');
5887					var clickEL = $('.element[data-id="' + pid + '"]');
5888					var checkThisPage = (b.ONE && clickEL.length > 0) ? true : false;
5889					var page_num = $(this).attr('data-page');
5890					var row_id = $(this).closest('.latest-post-list-title').attr('data-id');
5891					if (checkThisPage) {
5892						scrollToBlock('.element[data-id="' + pid + '"] .tpl-forum-list-title[data-id="' + row_id + '"]', 1000);
5893						$('.element[data-id="' + pid + '"] .tpl-forum-list-title[data-id="' + row_id + '"]').click();
5894						// $.removeCookie('forum_content_view', { path: '/', expires: 12 * 60 * 60 * 1000 });
5895						return false;
5896					} else {
5897						$.cookie(type + '-item', pid, { path: '/' });
5898						$.cookie('forum_content_view', pid + '&' + row_id, { path: '/', expires: 12 * 60 * 60 * 1000 });
5899						$.forum.setForumCookie(pid, page_num, '', '', '');
5900					};
5901				}
5902			}
5903
5904			//psearch - project item(pitem) click, set click parent
5905			if($(this).closest('.psearch-view').length > 0) {
5906				if(typeof $(this).attr('data-psearch-seq') != 'undefined') {
5907					$.cookie('gallery-item',$(this).attr('data-psearch-seq'), { path: '/' });
5908				} else {
5909					$.cookie('gallery',$(this).attr('data-psearch-pid'), { path: '/' });
5910				}
5911
5912				if(b.ONE && typeof $(this).attr('data-user-link') != 'undefined' &&  $(this).attr('data-user-link') == 'index') {
5913					location.replace('/');
5914					return false;
5915				}
5916			}
5917
5918			if (b.ONE) {
5919				if (userLink.charAt(0) == '/') {
5920					var linkRegExp = /\/view\//gi;
5921					var linkMatch = userLink.match(linkRegExp);
5922					if (linkMatch && linkMatch[0]) {
5923						var url = ((b.URL == '/') ? '' : b.URL) + userLink;
5924						if (target == '_blank') {
5925							var openNewWindow = window.open('about:blank');
5926							openNewWindow.location.href = url;
5927						} else {
5928							location.href = url;
5929						}
5930						return false;
5931					}
5932
5933					userLink = userLink.charAt(0).replace('/', '') + userLink.slice(1);
5934					if (b.VIEW || target == '_blank') {
5935						var url = ((b.URL == '/') ? '' : b.URL) + '#' + userLink;
5936						if (b.VIEW && target != '_blank') {
5937							// location.href = url;
5938							url = new getLocation(url);
5939							golink(_this,url);
5940						} else {
5941							var openNewWindow = window.open('about:blank');
5942							openNewWindow.location.href = url;
5943						}
5944					} else {
5945						// if (b.ONE && b.MENULINK.indexOf(userLink) === -1) {
5946						// 	var modal = $(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['editor.link.menu.invalid'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70');
5947						// 	return false;
5948						// }
5949						moveLinkPage(userLink);
5950					}
5951				} else {
5952					alert('Invalid URL');
5953					return false;
5954				}
5955			} else {
5956				var url = ((b.URL == '/') ? '' : b.URL) + userLink;
5957				if (target == '_blank' || target == 'blank') {
5958					var openNewWindow = window.open('about:blank');
5959					openNewWindow.location.href = url;
5960				} else {
5961					// location.href = url;
5962					url = new getLocation(url);
5963					golink(_this,url);
5964				}
5965			}
5966		});
5967		
5968		/* [Block Bookmark link] Click ==> link-type: link-bookmark*/
5969		$('a[attr-bookmark],*[data-imglink="true"][attr-bookmark],.fr-custom-button[attr-bookmark],.fr-fic[attr-bookmark],[data-type="showcase"] .item[attr-bookmark]').live({
5970			click : function(e) {
5971				e.preventDefault();
5972
5973				var checkSidemobile = ($(this).closest('.clnav-sidemobile').length > 0) ? true : false;
5974				if(checkSidemobile) $.clnav.setMode('sidemobile-open',false);
5975
5976				if($.clnav.check()
5977					&& ($(this).closest('.clnav-nowrap-target').length > 0 || $(this).closest('.clnav-sidemobile').length > 0)
5978				) {
5979					/* .cl-nav[data-behavior="overflow-nowrap"] */
5980					if ($.clnav.d.isDrag) {
5981						e.stopImmediatePropagation();
5982						return false;
5983					}
5984				}
5985
5986				if(	$(this).is('[attr-bookmark=""]') 
5987					|| (typeof e.target.className == 'string' && e.target.className.indexOf('fa') > -1 && $(this).closest('header').hasClass('navbar-simple'))
5988				) {
5989					return false;
5990				}
5991
5992				var $aEle = $(this);
5993				var $targetEle = $(this).closest('.element[data-el]');
5994				var datatype = $targetEle.attr('data-type') ?? '';
5995				var isimglink = $targetEle && $targetEle.length && $targetEle.hasClass('imglink');
5996				var hasalink = $(this).hasClass('sha_link');
5997				var isshlink = $(this).is('[data-shlink]');
5998
5999				var link = ((datatype == 'showcase') && isimglink && isshlink) ? $(this).attr('data-shlink').replace(/^\@/g, '') : $(this).attr('href').replace(/^\@/g, '');
6000				if(typeof link == 'undefined') return false;
6001
6002				var target = '';
6003				if ((typeof $(this).attr('target') != 'undefined') 
6004					|| (typeof $(this).attr('data-blank') != 'undefined')
6005				) {
6006					if ((datatype == 'showcase') && isimglink && isshlink) {
6007						target = $(this).attr('data-blank');
6008					} else {
6009						target = $(this).attr('target');
6010					}
6011				}
6012
6013				$.removeCookie('gallery', { path: '/' });
6014				$.removeCookie('gallery-item', { path : '/' });
6015				$.removeCookie('forum', { path : '/' });
6016				$.removeCookie('forum-item', { path : '/' });
6017
6018				var blockBookmarkList = (typeof b.SETTINGS.blockBookmarkList != 'undefined' && b.SETTINGS.blockBookmarkList) ? b.SETTINGS.blockBookmarkList : {};
6019				var hideArray = blockBookmarkList?.hide || [];
6020				if (hideArray.length > 0 && hideArray.includes(link)) {
6021					return false;
6022				}
6023
6024				if (typeof $(this).attr('attr-bookmark') != 'undefined' && (link != $(this).attr('attr-bookmark'))) link = $(this).attr('attr-bookmark');
6025				if($('.element[data-bookmark="' + link + '"]').length > 0 && target != '_blank') {
6026					var $bookmarkTarget = $('.element[data-bookmark="' + link + '"]').first();
6027					var bookmarkPage = $bookmarkTarget.attr('data-pagename') || b.PAGE;
6028					var moveCurrentBookmark = function() {
6029						var bookmarkGroup = getTabmenuGroupByPage(bookmarkPage);
6030						if (bookmarkGroup && window.clTabmenu && typeof window.clTabmenu.activateSectionPage == 'function') {
6031							window.clTabmenu.activateSectionPage(bookmarkPage, getRenderMenuUid(bookmarkGroup));
6032						}
6033						moveLinkPage(b.PAGE + '\@' + link, 1200, true, true);
6034					};
6035					var currentBookmarkMenu = getRenderMenuPageMap(property.SMENU || [])[normalizeRenderMenuLinkPage(bookmarkPage)] || null;
6036					requestMenuPageAccess(bookmarkPage, getRenderMenuUid(currentBookmarkMenu), moveCurrentBookmark);
6037				} else {
6038					if (typeof b.SETTINGS.blockBookmarkList == 'undefined' || !b.SETTINGS.blockBookmarkList || typeof b.SETTINGS.blockBookmarkList['bookmark' + link] == 'undefined') {
6039						$aEle.find('img[data-attach="true"]').unwrap();
6040						return false;
6041					}
6042
6043					$.post('/template/bookmarkBlock', {sid: b.SID, seq: link, publish : b.PUBLISH}, function(data) {
6044						if(!$.isArray(data) || !data[0] || typeof data[0].page != 'string' || !data[0].page) {
6045							// console.log('Block Link Click :( Undefined block');
6046							return false;
6047						}
6048
6049						var d = data[0];
6050						if(typeof d.orgpage != 'string' || d.orgpage.length == 0) d.orgpage = d.page;
6051
6052						var	org_title = d.orgpage.replace(/-/g,' ');
6053						var bb_o_page = (d.page.match(/^index/g) !== null ) ? org_title : d.page;
6054						var bb_page = (bb_o_page.match(/\,/g) !== null) ? bb_o_page.substring(0,d.page.indexOf('\,')) : bb_o_page;
6055
6056						var check_link = true;
6057						var is_visible_menu = false;
6058						$.each(b.SMENU, function (idx, obj) {
6059							if(bb_page == obj.name.replace(/ /g,'-')) {
6060								if(!obj.link) check_link = false;
6061								if(obj.display == 'on') is_visible_menu = false;
6062							}
6063							if(obj.children) {
6064								$.each(obj.children, function (i, v){
6065									if(bb_page == v.name.replace(/ /g,'-')) {
6066										if(!v.link) check_link = false;
6067										if(v.display == 'on') is_visible_menu = false;
6068									}
6069								});
6070							}
6071						});
6072
6073						var is_here = ($('.element[data-bookmark="' + link + '"]').length > 0 ) ? true : false;
6074						var is_page = (b.PAGE.toLowerCase()==d.page.toLowerCase()) ? true : false;
6075						// var is_visible_menu = ($.inArray(bb_page,b.MENULINK)>-1) ? true : false;
6076						// var check_link = ( $('#tpl-menu li a[href*="'+bb_page+'"]').length > 0 && $('#tpl-menu li a[href*="'+bb_page+'"]').text().trim().replace(/ /gi,'-') == bb_page ) ? false : true;
6077						var is_link = ( check_link && is_visible_menu && org_title != 'INTRO' ) ? true : false;
6078						var is_visible = (check_link && is_visible_menu && org_title != 'INTRO') ? true : false;
6079						var clearBookmarkGalleryCategory = function() {
6080							if(typeof d.gpid == 'undefined' || !d.gpid) return;
6081
6082							$.cookie('gallery-category-' + d.gpid, '', { path : '/', expires: 12 * 60 * 60 * 1000 });
6083						};
6084						var moveBookmarkPage = function() {
6085							if (!property.ONE && normalizeRenderMenuLinkPage(d.page) != normalizeRenderMenuLinkPage(property.PAGE)) {
6086								markPageClickMove(d.page);
6087							}
6088							moveBookmark(d.page, '\@' + link, 1200, target);
6089						};
6090						var moveBookmarkPageWithAccess = function() {
6091							var bookmarkMenu = getRenderMenuPageMap(property.SMENU || [])[normalizeRenderMenuLinkPage(bb_page)] || null;
6092							requestMenuPageAccess(bb_page, getRenderMenuUid(bookmarkMenu), moveBookmarkPage);
6093						};
6094
6095						if( ( !is_visible_menu && bb_page!='index' ) || 
6096							( typeof d.glivisible!='undefined' && d.glivisible ) ||
6097							( /*( (is_here && target=='_blank') || !is_page ) &&*/ ( is_link || is_visible ) ) ||
6098							( !is_here && is_page )
6099						)  {
6100								if(is_visible_menu == false) {
6101									if(b.SID == 'chansolpf') clearBookmarkGalleryCategory();
6102									moveBookmarkPageWithAccess();
6103								} else {
6104									$aEle.find('img[data-attach="true"]').unwrap();
6105									return false;
6106								}
6107						} else {
6108							if(b.SID == 'chansolpf') clearBookmarkGalleryCategory();
6109							moveBookmarkPageWithAccess();
6110						}
6111
6112					}, 'json');
6113				}
6114
6115			}
6116		});
6117
6118		$('[data-type="showcase"] .item[attr-link]').live('click',function(e) {
6119			var link = $(this).attr('href');
6120			var target = $(this).attr('target');
6121			var $targetEle = $(this).closest('.element[data-el]');
6122			var datatype = $targetEle.attr('data-type') ?? '';
6123
6124			if ((datatype == 'showcase') && $(e.target).closest('button, a').length > 0) {
6125				return;
6126			}
6127
6128			if (link) {
6129				if (target === '_blank') {
6130					window.open(link);
6131				} else {
6132					location.href = link;
6133				}
6134			}
6135		});
6136
6137		/* [File link] Click ==> link-type: link-file*/
6138		$('a[attr-flink], .fr-custom-button[attr-flink], .fr-fic[attr-flink]').live({
6139			click : function(e) {
6140				e.preventDefault();
6141
6142				if($.clnav.check()
6143					&& ($(this).closest('.clnav-nowrap-target').length > 0 || $(this).closest('.clnav-sidemobile').length > 0)
6144				) {
6145					/* .cl-nav[data-behavior="overflow-nowrap"] */
6146					if ($.clnav.d.isDrag) {
6147						e.stopImmediatePropagation();
6148						return false;
6149					}
6150				}
6151
6152				if(	$(this).is('[attr-flink=""]')
6153					|| (typeof e.target.className == 'string' && e.target.className.indexOf('fa') > -1 && $(this).closest('header').hasClass('navbar-simple'))
6154					|| (!property.VALIDPLAN || property.VALIDTYPE == 'PK')
6155				) {
6156					return false;
6157				}
6158
6159				var id = $(this).attr('attr-flink');
6160				if(typeof id == 'undefined' || !id) { 
6161					return false;
6162				} else {
6163					// direct download
6164					// var flink_url = location.protocol + '//' + location.host +'/down/flink/' + id;
6165					// window.open(flink_url);
6166
6167					// modal open
6168					$.getJSON('/down/flink/get/id/' + id , {}, function (data) {
6169						checkError(data);
6170						if(typeof data.data == 'object' && !$.isEmptyObject(data.data)) {
6171							var flink_link = data.data;
6172							var flinkDownModal = $(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['editor.link.file.download.check'], true, true, function() {
6173								var flink_url = location.protocol + '//' + location.host +'/down/flink/' + id + '/sid/' + flink_link.sid + '/s/' + encodeURIComponent(flink_link.file) + '/name/' + encodeURIComponent(flink_link.name);
6174								window.open(flink_url);
6175								flinkDownModal.modal('hide');
6176							}, 'cancel', 'ok');
6177						} else {
6178							return false;
6179						}
6180					}, 'json');
6181				}
6182
6183			}
6184		});
6185
6186		$('.element img[data-attach="true"][data-img-original="ON"]').live({
6187			click: function(e) {
6188				$(this).mouseenter();
6189			},
6190			mouseenter : function(e) {
6191				if(!selectEL || typeof selectEL == 'undefined') {
6192					selectEL = $(this).closest('.element').attr('data-el');
6193				}
6194				if(typeof selectEL == 'undefined') return false;
6195
6196				var offset = $(this).offset(),
6197			        left = $(this).width() + offset.left-25,
6198					top = offset.top;
6199				var index = $('.' + selectEL + ' img[data-attach="true"]').index(this);
6200
6201				if(b.VIEW) {
6202					var src = $(this).prop('src').split('/'),
6203						file = src[src.length-1];
6204		            if(src.indexOf('googleusercontent') > -1) {
6205		            	file = src;
6206		            }
6207					$('.config-image-view').css({ top : top + 'px', left : left + 'px' }).attr('data-src',$(this).prop('src')).attr('data-index',index).show();
6208				}
6209			},
6210			mouseleave : function(e) {
6211				$('.config-image-view').hide();
6212			}
6213		});
6214
6215		$('.config-image-view').live({
6216			mousemove : function(e) { $('.config-image-view').show(); },
6217			mouseout : function(e) { $('.config-image-view').show(); }
6218		});
6219
6220	    $('.config-image-view').on({
6221			click: function (e) {
6222				$('.config-image-view').hide();
6223
6224				var src = $(this).attr('data-src').split('/'),
6225					file = src[src.length-1],
6226	                free = (src[4]=='free') ? true : false;
6227
6228	            var img_src = $(this).attr('data-src')
6229	            if(img_src.indexOf('googleusercontent') > -1) {
6230	            	file = img_src;
6231	            }
6232	            file = Base64.encode(file);
6233				if(b.SID && file) {
6234					$('.tooltip.in').removeClass('in');
6235			  		$(this).attr("href","/image/original/sid/" + b.SID + "/file/" + file + '/free/' + free);
6236				} else {
6237					// console.log('None:: sid or src');
6238					return false;
6239				}
6240	        }
6241	    });
6242
6243		$('[data-lock-password]').live({
6244			'keydown.autocomplete': function(e) {
6245			    if (e.keyCode == 13) {
6246			    	$('[data-lock-submit]').click();
6247				}
6248			},
6249			'keyup': function() {
6250				if ($(this).val()) {
6251					$('[data-lock-submit]').addClass('btn-primary');
6252				} else {
6253					$('[data-lock-submit]').removeClass('btn-primary');
6254				}
6255			}
6256		});
6257
6258		$('.form-control[type="number"]').live('keydown', function(e) {
6259			if (e.keyCode == 109 || e.keyCode == 189) {
6260				return false;
6261			}
6262		});
6263
6264		var getSubmitCaptchaLang = function($parent) {
6265			var blocklang = $parent.attr('data-blocklang') || $parent.data('blocklang') || LANG;
6266			if(typeof $.lang == 'undefined' || typeof $.lang[blocklang] == 'undefined') blocklang = LANG;
6267			return blocklang;
6268		}
6269
6270		var getSubmitCaptchaText = function(blocklang, key, fallback) {
6271			if(typeof $.lang != 'undefined' && typeof $.lang[blocklang] != 'undefined' && typeof $.lang[blocklang][key] != 'undefined') return $.lang[blocklang][key];
6272			if(typeof $.lang != 'undefined' && typeof $.lang[LANG] != 'undefined' && typeof $.lang[LANG][key] != 'undefined') return $.lang[LANG][key];
6273			return fallback;
6274		}
6275
6276		var isSubmitCaptchaUserLoggedIn = function() {
6277			var pageMode = (typeof PAGE_MODE != 'undefined') ? PAGE_MODE : '',
6278				umember = (pageMode == 'c') ? ((typeof UMEMBER != 'undefined') ? UMEMBER : {}) : ((typeof property != 'undefined' && typeof property.UMEMBER != 'undefined') ? property.UMEMBER : {}),
6279				umemberActivate = (pageMode == 'c') ? ((typeof UMEMBER_ACTIVATE != 'undefined') ? Number(UMEMBER_ACTIVATE) : 0) : ((typeof property != 'undefined' && typeof property.UMEMBER_ACTIVATE != 'undefined') ? Number(property.UMEMBER_ACTIVATE) : 0),
6280				checkLogin = (pageMode == 'c') ? true : !!umember.check_login;
6281
6282			if(pageMode == 's' && umemberActivate == 0 && umember.id_type == 'creatorlink') {
6283				checkLogin = (umember.id !== undefined && umember.id) ? true : false;
6284			}
6285
6286			return checkLogin;
6287		}
6288
6289		var isSubmitCaptchaRequired = function($parent) {
6290			if(isSubmitCaptchaUserLoggedIn()) return false;
6291			if($parent.attr('data-type') == 'form') return false;
6292			return ($parent.attr('data-captcha') == 'true');
6293		}
6294
6295		var getInlineFormCaptcha = function($parent) {
6296			if($parent.attr('data-type') != 'form') return '';
6297			if(isSubmitCaptchaUserLoggedIn()) return '';
6298			return $.trim($parent.find('.form-captcha .input-captcha').val());
6299		}
6300
6301		var getSubmitCaptchaHTML = function(blocklang) {
6302			var captchaTip = getSubmitCaptchaText(blocklang, 'form.item.captcha-tip', '');
6303
6304			return '\
6305				<div class="form-group form-captcha">\
6306					<div class="kcaptcha-wrap display-flex">\
6307						<div class="kcaptcha-box">\
6308							<img src="//storage.googleapis.com/i.addblock.net/forum/captcha_sample_Img.jpg" class="kcaptcha-img" alt="' + captchaTip + '" title="' + captchaTip + '">\
6309						</div>\
6310						<div class="text-left kcaptcha-key-wrap">\
6311							<input type="text" name="wr_key" class="col-xs-12 col-sm-12 col-md-12 ed input-bg-opacity input-captcha" placeholder="' + getSubmitCaptchaText(blocklang, 'form.item.captcha.placeholder', 'CAPTCHA') + '" autocomplete="off">\
6312							<a href="#" class="kcaptcha-change hand small fsize12"><svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 12C4.33 12 2.92 11.42 1.75 10.25C0.58 9.08 0 7.67 0 6C0 4.33 0.58 2.92 1.75 1.75C2.92 0.58 4.33 0 6 0C6.9 0 7.74 0.19 8.51 0.56C9.28 0.93 9.94 1.44 10.5 2.06V0H12V5H7V3.5H9.73C9.33 2.89 8.8 2.4 8.15 2.04C7.5 1.68 6.78 1.5 6 1.5C4.75 1.5 3.69 1.94 2.81 2.81C1.93 3.68 1.5 4.75 1.5 6C1.5 7.25 1.94 8.31 2.81 9.19C3.68 10.07 4.75 10.5 6 10.5C7.17 10.5 8.17 10.11 9 9.34C9.83 8.57 10.31 7.62 10.44 6.5H11.98C11.85 8.06 11.22 9.36 10.08 10.42C8.94 11.48 7.58 12 6 12Z" fill="#8E9095"/></svg>
6312' + getSubmitCaptchaText(blocklang, 'form.item.captcha-change', 'Refresh') + '</a>\
6313						</div>\
6314					</div>\
6315				</div>\
6316			';
6317		}
6318
6319		var showSubmitCaptchaError = function($modal, blocklang, errorKey) {
6320			if(!$modal || $modal.length == 0) return;
6321
6322			var message = getSubmitCaptchaText(blocklang, errorKey, '');
6323			if(!message) message = getSubmitCaptchaText(blocklang, 'form.item.captcha.wrong', 'Invalid CAPTCHA code.');
6324
6325			$modal.find('.form-captcha .error').remove();
6326			$modal.find('.form-captcha').append('<div class="error">' + message + '</div>').addClass('required');
6327			$modal.find('.input-captcha').focus();
6328		}
6329
6330		var reloadSubmitCaptcha = function($modal, pid) {
6331			if(!$modal || $modal.length == 0) return;
6332			$modal.find('.input-captcha').val('');
6333			$modal.find('.form-captcha .error').remove();
6334			$modal.find('.form-captcha').removeClass('required');
6335			load_form_kcaptcha($modal, pid);
6336		}
6337
6338		var hideSubmitCaptchaModal = function($modal) {
6339			if(!$modal || $modal.length == 0) return;
6340			$modal.find('input:focus, textarea:focus, select:focus').blur();
6341			$modal.modal('hide');
6342		}
6343
6344		var showSubmitCaptchaModal = function($parent, pid, callback) {
6345			var blocklang = getSubmitCaptchaLang($parent);
6346			var modal = $(document.body).showModalFlat(
6347				getSubmitCaptchaText(blocklang, 'form.item.captcha.title', '보안 확인'),
6348				getSubmitCaptchaHTML(blocklang),
6349				true,
6350				true,
6351				function() {
6352					var captcha = $.trim(modal.find('.input-captcha').val());
6353					if(captcha == '') {
6354						showSubmitCaptchaError(modal, blocklang, 'config.wrong-captcha');
6355						return false;
6356					}
6357
6358					if(typeof callback == 'function') callback(captcha, modal, blocklang);
6359				},
6360				'cancel',
6361				'ok',
6362				'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 form-captcha-submit-modal',
6363				true
6364			);
6365
6366			reloadSubmitCaptcha(modal, pid);
6367			modal.find('.kcaptcha-change').off('click.submitCaptcha').on('click.submitCaptcha', function(e) {
6368				e.preventDefault();
6369				reloadSubmitCaptcha(modal, pid);
6370			});
6371			modal.find('.input-captcha').off('keydown.submitCaptcha').on('keydown.submitCaptcha', function(e) {
6372				if(e.keyCode == 13) {
6373					modal.find('.ok-button-dialog').click();
6374					return false;
6375				}
6376			}).focus();
6377
6378			return modal;
6379		}
6380
6381		$('[data-form-submit]').live('click', function() {
6382			var is_templates = checkTemplateSite(b.SID),
6383				is_render = (window.location.pathname.match(/^\/render(\/|$)/) !== null);
6384			if(is_render && !isRenderFormSubmitAllowed()) return false;
6385			if($('#flat-modal').length || is_templates) return false;
6386			if($('#flat-modal').length) return;
6387			var $parent = $(this).closest('.element'),
6388				$items = $parent.find('[form-idx]'),
6389				values = {},
6390				pid = $parent.attr('data-id'),
6391				submit = true,
6392				el = '.' + $(this).parents('.element').attr('data-name');
6393
6394			if($parent.find('.required').length > 0) {
6395				$parent.find('.form-inline').removeClass('required required-mr required-privacy');
6396				$parent.find('.form-group').removeClass('required');
6397			}
6398
6399			$parent.find('.error').remove();
6400			$.each($items, function(i,v) {
6401				var idx = $(this).attr('form-idx'),
6402					name = $(this).attr('form-name'),
6403					type = $(this).attr('form-type'),
6404					require = $(this).attr('form-require'),
6405					seq = $(this).attr('form-seq');
6406
6407				switch(type) {
6408					case "radio":
6409					case "check":
6410					case "radio.image":
6411					case "check.image":
6412						if(type == 'radio' || type == 'radio.image') {
6413							var val = $(this).find(':radio[name]:checked').val();
6414							values[seq] = (typeof val == 'undefined') ? '' : val;
6415						} else {
6416							values[seq] = $(this).find(':checkbox[name]:checked').map(function() { return this.value; } ).get().join();
6417						}
6418
6419						if(typeof require != 'undefined' && require) {
6420							if(!values[seq]) {
6421								formRequireDisplay($(this),i+1);
6422								submit = false;
6423							}
6424						}
6425						break;
6426					case "date":
6427						var date = $(this).find('input').map(function() { return this.value.replace(/-/g, ''); } ).get(),
6428							valid = true;
6429
6430						$.each(date, function(k,d) {
6431							if(d=='') valid = false;
6432						});
6433
6434						if(typeof require != 'undefined' && require) {
6435							if(valid == false) {
6436								formRequireDisplay($(this),i+1);
6437								submit = false;
6438							}
6439						}
6440						values[seq] = date.join('');
6441						break;	
6442					case "date2":
6443						var date = $(v).find('input').val();
6444						if($(v).find('input').length > 1 && $(v).find('.date-yyyy').length > 0) { //old
6445							var ymd = $(v).find('.date-yyyy').val() + '-' + $(v).find('.date-mm').val() + '-' + $(v).find('.date-dd').val();
6446							var time = $(v).find('.date-hh').val() + ':' + $(v).find('.date-ii').val();
6447							date = ymd + ' ' + time;
6448						}
6449						values[seq] = date;
6450						if(typeof require != 'undefined' && require) {
6451							if(!values[seq]) {
6452								formRequireDisplay($(this),i+1);
6453								submit = false;
6454							}
6455						}
6456						
6457						break;
6458					case "file.upload":
6459						var fileArr = new Array();
6460						$(this).find('input[type="hidden"]').each(function(idx, v) {
6461							var f = '#FILE#||' + $(v).val();
6462							fileArr.push(f);
6463						});
6464
6465						var val = fileArr.join(',');
6466                        values[seq] = (typeof val == 'undefined') ? '' : val;
6467
6468                        if(typeof require != 'undefined' && require) {
6469                            if(!values[seq].replace('#FILE#||', '')) {
6470                                formRequireDisplay($(this),i+1);
6471                                submit = false;
6472                            }
6473                        }
6474						break;
6475					default :
6476						var itemValue = $(this).hasClass('franchise-form-select') ? $(this).find('select.franchise-form-select-native').val() : $(this).val();
6477						values[seq] = (typeof itemValue == 'undefined' || itemValue === null) ? '' : itemValue.toString().trim();
6478						if(values[seq] && checkEmojis(values[seq])) {
6479							formRequireDisplay($(this),i+1,'emoji');
6480							submit = false;
6481						} else if(typeof require != 'undefined' && require) {
6482							if(!values[seq]) {
6483								formRequireDisplay($(this),i+1);
6484								submit = false;
6485							}
6486						}
6487						break;
6488				}
6489			});
6490
6491			var $privacy = $parent.find('.form-privacy'),
6492				check;
6493
6494			if($privacy.css('display')!='none') {
6495				check = $privacy.find('.check-privacy').prop('checked');
6496				if(check === false) {
6497					formRequireDisplay($privacy.find('.check-privacy'),'privacy');
6498					submit = false;
6499				}
6500			}
6501
6502			if($parent.attr('data-type') == 'form') {
6503				var $captcha = $parent.find('.form-captcha');
6504				var formCaptcha = '';
6505
6506				if($captcha.length > 0) {
6507					formCaptcha = $captcha.find('.input-captcha').val();
6508					if(formCaptcha == '') {
6509						formRequireDisplay($captcha.find('.input-captcha'),'captcha');
6510						submit = false;
6511					}
6512				}
6513			} else {
6514				var captcha_display = isSubmitCaptchaRequired($parent);
6515				$parent.find('.form-captcha').remove();
6516			}
6517
6518			if(!$parent.hasClass('el-fixedcontact') && $('.form-inline .error').length > 0) {
6519				var $error = $parent.find('.error');
6520				var header_height = $('.navbar-fheader').height();
6521				$.each($error, function(i,v) {
6522					if(i==0) {
6523						var $form_group = $(v).parent().find('[form-type]');
6524						var type = $form_group.attr('form-type');
6525						var privacy = $(v).parent().hasClass('form-privacy');
6526						if($.inArray(type, ['radio', 'check', 'radio.image', 'check.image']) > -1 || privacy) {
6527							var form_offset = $(v).parents('.form-group').offset();
6528							$("html, body").animate({scrollTop: ($parent.attr('data-type') == 'form')? form_offset.top-header_height : $parent.offset().top-header_height});
6529						} else {
6530							$(v).parent().find('.form-control').first().focus();
6531						}
6532					}
6533				});
6534			}
6535
6536				if(submit) {
6537					var completeSubmitForm = function(doneText) {
6538						var message = doneText;
6539						if(!message) message = $parent.attr('data-form-done');
6540						if(!message && typeof $.lang != 'undefined' && typeof LANG != 'undefined' && $.lang[LANG]) {
6541							message = $.lang[LANG]['forms.submit.done'];
6542						}
6543						if(!message) message = (typeof LANG != 'undefined' && LANG == 'ko') ? '신청 완료되었습니다.' : 'Your submission has been received';
6544
6545						$(this).showModalFlat('INFORMATION', message, true, false, '', 'ok', '', 'cl-modal cl-none-title cl-cmmodal cl-p130 cl-s-btn w560','','',function(){
6546							if(typeof formCallback == 'function') formCallback(pid);
6547						});
6548
6549						setDefaultForm(el);
6550					};
6551					var submitForm = function(formCaptcha, captchaModal, captchaBlocklang) {
6552						$.processON();
6553						$.ajax({
6554							url: '/template/forms/submit',
6555							data: { sid : b.SID, pid : pid, values : values, check : check, captcha : formCaptcha, block_type: 'form' },
6556							dataType: 'json',
6557							type: 'POST',
6558							async: true,
6559							cache: false,
6560							success: function (data) {
6561								checkError(data);
6562
6563								if(typeof data.error != 'undefined' && data.error != '') {
6564								// $(this).showModalFlat('', data.error,true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn','','',function() {
6565								// 	$(document).on('keydown', function(e) {
6566								// 		if(e.keyCode == 27) modal.modal('hide');
6567								// 	});
6568								// });
6569								return false;
6570							}
6571
6572								if(typeof data.captcha_error != 'undefined' && data.captcha_error != '') {
6573									if(captchaModal && captchaModal.length > 0) {
6574										reloadSubmitCaptcha(captchaModal, pid);
6575										showSubmitCaptchaError(captchaModal, captchaBlocklang, data.captcha_error);
6576									} else if($parent.attr('data-type') == 'form' && $parent.find('.form-captcha').length > 0) {
6577										reloadSubmitCaptcha($parent, pid);
6578										showSubmitCaptchaError($parent, getSubmitCaptchaLang($parent), data.captcha_error);
6579									} else {
6580										alert($.lang[LANG][data.captcha_error]);
6581									}
6582									return false;
6583								}
6584
6585								if(captchaModal && captchaModal.length > 0) hideSubmitCaptchaModal(captchaModal);
6586								completeSubmitForm.call(this, data.done);
6587							},
6588							error: function(xhr) {
6589								// DB 저장 후 알림 발송 지연으로 502가 반환되는 경우 제출 완료 상태로 처리한다.
6590								if(xhr && xhr.status == 502) {
6591									if(captchaModal && captchaModal.length > 0) hideSubmitCaptchaModal(captchaModal);
6592									completeSubmitForm.call(this);
6593								}
6594							},
6595							complete: function() {
6596								$.processOFF();
6597							}
6598						},'json');
6599					};
6600
6601					if(captcha_display) {
6602						showSubmitCaptchaModal($parent, pid, function(captcha, captchaModal, captchaBlocklang) {
6603							submitForm(captcha, captchaModal, captchaBlocklang);
6604						});
6605					} else {
6606						submitForm(getInlineFormCaptcha($parent), null, getSubmitCaptchaLang($parent));
6607					}
6608				}
6609			});
6610
6611		var formRequireDisplay = function($obj,idx,error_type) {
6612			if(typeof error_type == 'undefined') error_type = '';
6613
6614			var isModoo = $obj.parents('.element').hasClass('modoo');
6615
6616			var blang = $obj.parents('.element').attr('data-lang'),
6617				sdefault = '';
6618
6619			var $el = $obj.parents('.element');
6620
6621			if(typeof property.SLANG.select != 'undefined') {
6622				var _lang = property.SLANG.select;
6623				if(_lang.indexOf('한국어') > -1) {
6624					sdefault = '필수 입력 사항';
6625				} else if(_lang.indexOf('English') > -1) {
6626					sdefault = 'Required';
6627				} else if(_lang.indexOf('日本語') > -1) {
6628					sdefault = '必須';
6629				} else {
6630					sdefault = 'Required';
6631				}
6632			} else sdefault = '필수 입력 사항';
6633
6634
6635			if(error_type == 'emoji') {
6636				sdefault = $.lang[LANG]['config.unable.emoji'];
6637			}
6638			
6639			var $parent = (isModoo) ? $obj.parents('.box') : $obj.parents('.form-group'),
6640				$html = $('<div class="error">' + sdefault + '</div>');
6641			$parent.append($html);
6642			if($obj.parents('.form-inline').find('.error').length==1) {
6643				if(isNumber(idx)) $('body').scrollTo($('[form-idx="' + idx + '"]'), 0, { offset : -150 } );
6644				else  $('body').scrollTo($parent, 0, { offset : -150 } );
6645			}
6646			if($el.attr('data-type') == 'contact' && $el.attr('data-type2') == 'franchise bar') {
6647				$parent.addClass('required');
6648				$el.find('.form-inline').addClass('required');
6649
6650				if($parent.hasClass('form-privacy')) {
6651					$el.find('.form-inline').addClass('required-privacy');
6652				} else {
6653					if(idx > 2) {
6654						$el.find('.form-inline').addClass('required-mr');
6655					}
6656				}
6657			}
6658		}
6659
6660		$('.date-yyyy').live('keyup', function(e) {
6661			var val = $(this).val();
6662			if(val.length>=4) {
6663				if((e.target.selectionStart).length) ;
6664				else {
6665					if(isNaN(parseInt(val))) {
6666						$(this).val('1900');
6667					}
6668					$(this).parents('.form-group').find('.date-mm').focus();
6669				}
6670			}				
6671		}).live('blur', function(e) {
6672			var val = $(this).val();
6673			if(isNaN(parseInt(val))) {
6674				$(this).val('1900');
6675			} else {
6676				if(parseInt(val)<1900) {
6677					$(this).val('1900');
6678				}
6679			}
6680		});
6681
6682		$('.date-mm, .date-dd, .date-hh, .date-ii').live('keyup', function(e) {
6683			var val = $(this).val();
6684			if(val.length>=2) {
6685				if((e.target.selectionStart).length) ;
6686				else {
6687					if(isNaN(parseInt(val))) {
6688						$(this).val('00');
6689					}
6690					if($(this).hasClass('date-mm')) {
6691						$(this).parents('.form-group').find('.date-dd').focus();
6692					} else if($(this).hasClass('date-dd')) {
6693						$(this).parents('.form-group').find('.date-hh').focus();
6694					} else if($(this).hasClass('date-hh')) {
6695						$(this).parents('.form-group').find('.date-ii').focus();
6696					} else if($(this).hasClass('date-ii')) {
6697						// $(this).parents('.form-group').next().find('input').focus();
6698					}
6699				}
6700			}				
6701		}).live('blur', function(e) {
6702			var val = $(this).val();
6703			if(isNaN(parseInt(val))) {
6704				$(this).val('01');
6705			} else {
6706				if(val.length==1) {
6707					$(this).val('0' + val);
6708				} else {
6709					if($(this).hasClass('date-mm') && parseInt(val)>12) {
6710						$(this).val('12');
6711					} else if($(this).hasClass('date-dd') && parseInt(val)>31) {
6712						$(this).val('31');
6713					} else if($(this).hasClass('date-hh') && parseInt(val)>23) {
6714						$(this).val('00');
6715					} else if($(this).hasClass('date-ii') && parseInt(val)>59) {
6716						$(this).val('00');
6717					}
6718				}
6719			}
6720		});
6721
6722		$('[data-lock-submit]').live('click', function() { 
6723			var el = $(this).closest('.form-inline');
6724			var pw = el.find('[data-lock-password]').val().trim();
6725			if(pw.length == 0 ) {
6726				el.find('[data-lock-password]').focus();
6727				el.find('.error-text').text('! ' + $.lang[LANG]['config.enter-password']);
6728				return false;
6729			}
6730
6731			$.modalON();
6732			let lockType = $(this).attr('data-lock');
6733			var url = (lockType == 'site')? '/template/siteLockController/type/pw_check':'/template/menuLockController/type/pw_check';
6734			$.post(url, {s: b.SMENU, sid: b.SID, page: b.PAGE, pw: pw, publish : b.PUBLISH}, function(data) {
6735				checkError(data);
6736				$.modalOFF();
6737				if(data.result) {
6738					if(lockType == 'site' && data.ss_site_lock) {
6739						localStorage.setItem('ss_' + b.SID + '_site_lock', data.ss_site_lock);
6740						localStorage.setItem('last_activity', data.last_activity);
6741					}
6742					window.location.reload(true);
6743				} else {
6744					el.find('[data-lock-password]').focus();
6745					el.find('.error-text').text('! ' + $.lang[LANG]['siteum.regexp.pw.invalid']);
6746				}
6747			}, 'json');
6748		});
6749
6750		$('[data-contact-submit]').live('click',function(e) {
6751			var is_templates = checkTemplateSite(b.SID),
6752				is_render = (window.location.pathname.match(/^\/render(\/|$)/) !== null);
6753			if(is_render && !isRenderFormSubmitAllowed()) return false;
6754			// if($('#flat-modal').length || window.location != window.parent.location) return;
6755
6756			//템플릿 추가 화면에서만 버튼 동작 안 되게끔 처리
6757			if($('#flat-modal').length || is_templates) return;
6758			
6759			$.modalON();
6760
6761		    var el = '.' + $(this).parents('.element').attr('data-name'),
6762		    	el_id = $(this).parents('.element').attr('data-id'),
6763		    	google_track = $(this).attr('data-google-track'),
6764		    	google_track_run = false,
6765		    	daum_track = $(this).attr('data-daum-track'),
6766		    	daum_track_run = false,
6767		    	naver_track = $(this).attr('data-naver-track'),
6768		    	naver_track_run = false;
6769
6770			var hasEmoji = false;
6771			$(el+' .form-group .form-control:not([readonly])').each(function() {
6772				if(checkEmojis($(this).val().trim())) {
6773					hasEmoji = true;
6774					return false;
6775				}
6776			});
6777
6778			if(hasEmoji) {
6779				e.preventDefault();
6780				$.modalOFF();
6781				errorEmojisModal();
6782				return false;
6783			}
6784
6785			google_track_run = (typeof google_track != 'undefined') ? true : false;
6786			daum_track_run = (typeof daum_track != 'undefined') ? true : false;
6787			naver_track_run = (typeof naver_track != 'undefined') ? true : false;
6788
6789		    if($(el).length==0 || $(el).length>1) {
6790		        alert('Invalid form data');
6791		        return false;
6792		    }
6793
6794
6795		    var firstname = ($(el + ' [data-contact-firstname]').length >0 ) ? setDefaultValue($(el + ' [data-contact-firstname]').val().trim()) : '',
6796		    	lastname = 	($(el + ' [data-contact-lastname]').length > 0) ? setDefaultValue($(el + ' [data-contact-lastname]').val().trim()) : '',
6797		    	email = 	($(el + ' [data-contact-email]').length > 0) ? setDefaultValue($(el + ' [data-contact-email]').val().trim()) : '',
6798		    	web = 		($(el + ' [data-contact-website]').length > 0) ? setDefaultValue($(el + ' [data-contact-website]').val().trim()) : '',
6799		    	phone = 	($(el + ' [data-contact-phone]').length > 0) ? setDefaultValue($(el + ' [data-contact-phone]').val().trim()) : '' ,
6800		    	subject = 	($(el + ' [data-contact-subject]').length > 0) ? setDefaultValue($(el + ' [data-contact-subject]').val().trim()) : '',
6801		    	message = 	($(el + ' [data-contact-message]').length > 0) ? setDefaultValue($(el + ' [data-contact-message]').val().trim()) : '',
6802		    	etc = {};
6803    		$(el + ' [data-contact-etc]').each(function(i) {
6804				var key = $(this).attr('data-contact-etc');
6805				etc[key] = setDefaultValueEtc($(this).attr('type'),$(this));
6806			});
6807
6808		    var require_firstname 	= $(el + ' [data-contact-firstname]').attr('data-required'),
6809		    	require_lastname 	= $(el + ' [data-contact-lastname]').attr('data-required'),
6810		    	require_email		= $(el + ' [data-contact-email]').attr('data-required'),
6811		    	require_web			= $(el + ' [data-contact-website]').attr('data-required'),
6812		    	require_phone		= $(el + ' [data-contact-phone]').attr('data-required'),
6813		    	require_subject 	= $(el + ' [data-contact-subject]').attr('data-required');
6814
6815		    /*default:: required[email,message] | optional[firstname,lastname,web,phone,subject]  // data-optional='true'->optional, 'false'->required */
6816		    var optional_firstname  = $(el + ' [data-contact-firstname]').attr('data-optional'),
6817		    	optional_lastname   = $(el + ' [data-contact-lastname]').attr('data-optional'),
6818		    	optional_email		= $(el + ' [data-contact-email]').attr('data-optional'),
6819		    	optional_web		= $(el + ' [data-contact-web]').attr('data-optional'),
6820		    	optional_phone		= $(el + ' [data-contact-phone]').attr('data-optional'),
6821		    	optional_subject	= $(el + ' [data-contact-subject]').attr('data-optional'),
6822		    	optional_message	= $(el + ' [data-contact-message]').attr('data-optional');
6823		    var optional_etc		= {};
6824
6825    		$(el + ' [data-contact-etc]').each(function(i) {
6826				var key = $(this).attr('data-contact-etc');
6827				optional_etc[key] = $(this).attr('data-optional');
6828			});
6829
6830				var $parent = $(this).parents('.element'),
6831					el = '.' + $(this).parents('.element').attr('data-name'),
6832					contprivacy = $(el+' .form-group.contact-privacy-area').css('display'),
6833					contprivacy_display = (typeof contprivacy == 'undefined' || contprivacy == 'none') ? false : true,
6834					privacy_check = $parent.find('.contact-checkbox-text'),
6835					privacy_chk = privacy_check.is(":checked"),
6836					captcha_display = isSubmitCaptchaRequired($parent),
6837					check = true,
6838					check_option = [];
6839
6840				$parent.find('.form-captcha').remove();
6841
6842				if(!firstname) {
6843					var name_text = ($(el + ' [data-contact-lastname]').length > 0) ? 'first name' : 'name';
6844		    	if(typeof optional_firstname != 'undefined' && optional_firstname == 'false') check = true;
6845		    	else if ($(el + ' [data-contact-firstname]').length == 0) check 
6845= true;
6846		    	else check = false;
6847
6848		    	var str = ($(el + ' [data-contact-firstname]').length > 0 && $(el + ' [data-contact-firstname]').attr('data-contact-firstname').length > 0) ? $(el + ' [data-contact-firstname]').attr('data-contact-firstname') : name_text;
6849		    	if(!check) check_option.push(str);
6850		    }
6851
6852		    if($(el + ' [data-contact-lastname]').length > 0 && !lastname) {
6853		    	if(typeof optional_lastname != 'undefined' && optional_lastname == 'false') check = true;
6854		    	else if ($(el + ' [data-contact-lastname]').length == 0) check = true;
6855		    	else check = false;
6856		    	
6857		    	var str = ($(el + ' [data-contact-lastname]').attr('data-contact-lastname').length > 0) ? $(el + ' [data-contact-lastname]').attr('data-contact-lastname') : 'last name';
6858		    	if(!check) check_option.push(str);
6859		    }
6860
6861		    /*if((!firstname && typeof optional_firstname != 'undefined' && optional_firstname == "false") || (!lastname && typeof optional_lastname != 'undefined' && optional_lastname == "false")) {
6862		    	var str = ($(el + ' [data-contact-firstname]').attr('data-contact-firstname').length > 0) ? $(el + ' [data-contact-firstname]').attr('data-contact-firstname') : 'name';
6863		    	check_option.push(str);
6864		    }*/
6865		    
6866		    if(!web && typeof optional_web != 'undefined' && optional_web == 'false') {
6867		    	var str = ($(el + ' [data-contact-web]').attr('data-contact-web').length > 0) ? $(el + ' [data-contact-web]').attr('data-contact-web') : 'web';
6868		    	check_option.push(str);
6869		    }
6870
6871		    if(!phone && typeof optional_phone != 'undefined' && optional_phone == 'false') {
6872		    	var str = ($(el + ' [data-contact-phone]').attr('data-contact-phone').length > 0) ? $(el + ' [data-contact-phone]').attr('data-contact-phone') : 'phone';
6873		    	check_option.push(str);
6874		    }
6875
6876		    if(!subject && typeof optional_subject != 'undefined' && optional_subject == 'false') {
6877		    	var str = ($(el + ' [data-contact-subject]').attr('data-contact-subject').length > 0) ? $(el + ' [data-contact-subject]').attr('data-contact-subject') : 'subject';
6878		    	check_option.push(str);
6879		    }
6880
6881		    if(!email) {
6882		    	if(typeof optional_email != 'undefined' && optional_email == 'true') check = true;
6883		    	else if ($(el + ' [data-contact-email]').length == 0) check = true;
6884		    	else check = false;
6885		    	
6886		    	var str = ($(el + ' [data-contact-email]').attr('data-contact-email').length > 0) ? $(el + ' [data-contact-email]').attr('data-contact-email') : 'email';
6887		    	if(!check) check_option.push(str);
6888		    }
6889		    if(!message) {
6890		    	if(typeof optional_message != 'undefined' && optional_message == 'true') check = true;
6891		    	else check = false;
6892
6893		    	var str = ($(el + ' [data-contact-message]').attr('data-contact-message').length > 0) ? $(el + ' [data-contact-message]').attr('data-contact-message') : 'message';
6894		    	if(!check) check_option.push(str);
6895		    }
6896
6897		   	$.each(etc,function(k,v){
6898		   		if(!etc[k] && typeof optional_etc[k] != 'undefined' & optional_etc[k] == 'false') {
6899		   			check_option.push(k);
6900		   		}
6901		   	});
6902
6903		   	check = ((check_option.length == 0) && ((contprivacy_display == false) || (privacy_chk == true))) ? true : false;
6904
6905		    if(require_firstname == 'true' && !firstname) {
6906		    	$(this).showModalFlat('INFORMATION',$(el + ' [data-contact-firstname]').attr('placeholder') + $.lang[LANG]['check.required'], true, false, '', 'ok');
6907		    	return false;
6908		    }
6909
6910		    if(require_lastname == 'true' && !lastname) {
6911		    	$(this).showModalFlat('INFORMATION',$(el + ' [data-contact-lastname]').attr('placeholder') + $.lang[LANG]['message.check.required'], true, false, '', 'ok');
6912		    	return false;
6913		    }
6914
6915		    if(require_web == 'true' && !web) {
6916		    	$(this).showModalFlat('INFORMATION',$(el + ' [data-contact-website]').attr('placeholder') + $.lang[LANG]['message.check.required'], true, false, '', 'ok');
6917		    	return false;
6918		    }
6919
6920		    if(require_phone == 'true' && !phone) {
6921		    	$(this).showModalFlat('INFORMATION',$(el + ' [data-contact-phone]').attr('placeholder') + $.lang[LANG]['message.check.required'], true, false, '', 'ok');
6922		    	return false;
6923		    }
6924
6925		    if(require_subject == 'true' && !subject) {
6926		    	$(this).showModalFlat('INFORMATION',$(el + ' [data-contact-subject]').attr('placeholder') + $.lang[LANG]['message.check.required'], true, false, '', 'ok');
6927		    	return false;
6928		    }
6929
6930		    if(check) {
6931			var submitContact = function(contactCaptcha, captchaModal, captchaBlocklang) {
6932				$.modalON();
6933				$.post('/template/update/type/contact',{
6934					id : b.SID,
6935					seq : el_id,
6936					s : 'message',
6937					firstname : firstname,
6938					lastname : lastname,
6939					email : email,
6940					web : web,
6941					phone : phone,
6942					subject : subject,
6943					message : message,
6944					etc : JSON.stringify(etc),
6945						captcha : contactCaptcha,
6946						block_type: 'contact',
6947				}, function(data) {
6948					checkError(data);
6949						if(typeof data.captcha_error != 'undefined' && data.captcha_error != '') {
6950							$.modalOFF();
6951							if(captchaModal && captchaModal.length > 0) {
6952								reloadSubmitCaptcha(captchaModal, el_id);
6953								showSubmitCaptchaError(captchaModal, captchaBlocklang, data.captcha_error);
6954							} else {
6955								alert($.lang[LANG][data.captcha_error]);
6956							}
6957							return false;
6958						}
6959
6960					if(typeof data.error == 'undefined' || data.error == '') {
6961						var ch_lang = getLang($(el), b.SID),
6962							submit_txt = (typeof data.submitStr != 'undefined' && data.submitStr) ? data.submitStr : $.lang[ch_lang]['message.sent'];
6963
6964						if(captchaModal && captchaModal.length > 0) hideSubmitCaptchaModal(captchaModal);
6965						$(document.body).showModalFlat('INFORMATION',submit_txt,true,false, '', 'ok', '', 'cl-modal cl-none-title cl-cmmodal cl-p130 cl-s-btn w560');
6966						setDefaultContactForm(el);
6967						setDefaultContactFormEtc(el);
6968						if(typeof contactCallback == 'function')
6969							contactCallback(el_id);
6970					}
6971				},'json');
6972				    setTimeout(function() {
6973					    $.modalOFF();
6974				    },1000);
6975			};
6976
6977			if(captcha_display) {
6978				$.modalOFF();
6979				showSubmitCaptchaModal($parent, el_id, function(captcha, captchaModal, captchaBlocklang) {
6980					submitContact(captcha, captchaModal, captchaBlocklang);
6981				});
6982			} else {
6983				submitContact('', null, getSubmitCaptchaLang($parent));
6984			}
6985		    } else {
6986		    	$.modalOFF();
6987		    	var check_str = '';
6988		    	$.each(check_option,function(k,v) {
6989		    		check_str = (check_str) ? check_str + ' / ': '';
6990		    		check_str = check_str + v;
6991	            });
6992	            
6993		    	if(check_str) {
6994		    		var modal = $(this).showModalFlat('INFORMATION',check_str+ $.lang[LANG]['message.check.required'],true,false, '', 'ok', '', 'cl-modal cl-none-title cl-cmmodal cl-p130 cl-s-btn w560');
6995		    	} else {
6996		    		var modal = $(this).showModalFlat('INFORMATION',$.lang[LANG]['message.privacy.check.required'],true,false, '', 'ok');
6997		    	}
6998		    	
6999		    }					    
7000		});	
7001	
7002		$('.contact-privacy-text').live('click',function() {
7003			var contactEL = $(this).parents('.element'),
7004				contactPriavcy = $(contactEL).find('.form-inline .contact-privacy-area .contact-privacy-box'),
7005				checkType = (typeof $(contactEL).attr('data-type') != 'undefined' && $(contactEL).attr('data-type') == 'contact') ? true : false;
7006
7007			if(checkType && contactPriavcy.length > 0) {
7008				if(contactPriavcy.css('display') == 'none') contactPriavcy.show();
7009				else contactPriavcy.hide();
7010			}
7011		});
7012		
7013		$('.element .gallery-loadmore').live({
7014		    click: function(e) {
7015				if(typeof $(this).data('id') == 'undefined' || typeof $(this).data('page') == 'undefined') {
7016					e.preventDefault();
7017					return false;
7018				}
7019
7020				var id = $(this).attr('data-id'),
7021					gpage = (typeof $(this).attr('data-page') != 'undefined') ? Number($(this).attr('data-page')) : 1,
7022					view = (typeof $(this).attr('data-view') != 'undefined') ? Number($(this).attr('data-view')) : 6,
7023					mode = $(this).attr('data-mode'),
7024					$galleryELLoadmore = $(this),
7025					$galleryEL = $('.element[data-id="' + id + '"]'),
7026					$gContainer = $galleryEL.find('.container'),
7027					$gLoop = $galleryEL.find('[data-loop="true"]'),
7028					$gtoolbar = getGToolbar($galleryEL),
7029					$gc =  $gtoolbar.find('.cl-gcate-list .cl-gcate-item.active'),
7030		            $go = $gtoolbar.find('.cl-gsort-list .cl-gsort-item.active a'),
7031					sfl = ($gc.index() > 0) ? 'category' : '',
7032					stx = (sfl) ? $gc.text().trim() : '',
7033		            orderby = ($go.length > 0) ? $go.attr('data-orderby') : 'recent';
7034
7035		        var val = galleryEL[id],
7036		        	tag = htmlspecialchars_decode(val.eltag,'ENT_QUOTES'),
7037		        	g_settings = (typeof val.elsettings != 'undefined' && val.elsettings) ? $.parseJSON(val.elsettings) : {},
7038		        	folder = (typeof val.folder != 'undefined' && val.folder > 0) ? val.folder : '',
7039		        	isMasonry = $galleryELLoadmore.hasClass('masonry-layout'),
7040		        	block_lang = (typeof g_settings.blocklang != 'undefined') ? g_settings.blocklang : LANG;
7041
7042				var nodes = $gLoop.clone().children('.grid');
7043				initGalleryField(nodes);
7044
7045				var g_number = $gLoop.data('gallery-no'),
7046					total = 0,
7047					items = 0,
7048					gallery_item = '';
7049
7050				var checkLoadmoreInLoop = ($(tag).find('[data-loop="true"] .loadmore-wrap').length) ? true : false;
7051				var glm = $(tag).find('.loadmore-wrap');
7052
7053				var checkGallerySVG = ($(tag).find('.gimg-svg-wrap').length > 0) ? true : false,
7054					checkGFrameTitleOFF = (val.mode == 'gallery' && (typeof g_settings.gframe_title_visible != 'undefined' && g_settings.gframe_title_visible == 'OFF')) ? true : false;
7055
7056				if(id == 'all_products') {
7057		       		sfl = 'orderby';
7058		       		stx = (typeof $gc.find('a').attr('data-orderby') != 'undefined') ? $gc.find('a').attr('data-orderby') : $('.allProducts-sort-list>li:first-child').find('a').attr('data-orderby');
7059		       	}				
7060
7061		       	var checkUseComment = checkUseCommentFunc(val.mode, val.eltag);
7062				   var checkUseLike = checkUseLikeFunc(val.mode, val.eltag);
7063				var uri = getSearchURL();
7064				// if(uri.category_no == '') {
7065				// 	uri.category_no = (typeof g_settings.lux_category_no != 'undefined') ? g_settings.lux_category_no : '';
7066				// }
7067				if (isObjectEmpty(uri) && _this.b.LUX) {
7068					uri = val.searches.uri;
7069				}
7070	
7071		        $.ajax({
7072		            url: '/template/gallery/list/pid/' + id + '/sid/' + property.SID + '/spage/' + property.PAGE + '/page/' + gpage + '/view/' + view + '/publish/' + property.PUBLISH,
7073					data: { g_mode: mode, visible: true, sfl: sfl, stx: stx, orderby: orderby, total: true, uri : uri },
7074					dataType: 'json',
7075					type: 'POST',
7076		            async: false,
7077		            cache: false,
7078		            success: function (data) {
7079		            	$.cookie('gallery-page-' + id, gpage, { path: '/', expires: 12 * 60 * 60 * 1000 });
7080		                $.cookie('gallery-category-' + id, stx, { path: '/', expires: 12 * 60 * 60 * 1000 });
7081	                    $.cookie('gallery-orderby-' + id, orderby, { path: '/', expires: 12 * 60 * 60 * 1000 });
7082						if($galleryEL.is('[data-gjs]') && gpage > 1) setLoadmoreGalleryJS($galleryEL.attr('data-gjs'),id,true);
7083
7084		                var loop_count = nodes.length;
7085
7086                        total = (typeof data.total.list_total != 'undefined') ? data.total.list_total : data.total;
7087		                items = data.list.length;
7088
7089		                var g_popup_remove = $('.galleryPL'+id+'.gallery-popup').find('.gallery-item');
7090		                $.each(g_popup_remove,function(i,v) {
7091		                	if(items > i) $(this).remove();
7092		                });
7093
7094		                $.each(data.list,function(i,v) {
7095		                    loop_pos = i%loop_count;
7096		                    c = nodes[loop_pos];
7097		                    item_index = ((gpage-1)*view) + i;
7098                            var isTitle = (v.title.length > 0) ? true:false,
7099                                isCaption = (v.caption.length > 0) ? true:false;
7100
7101							$(c).addClass('gallery-item').attr('data-index',item_index).attr('data-gpos',v.pos).attr('data-seq',v.seq);
7102							
7103                            var vgsettings = (typeof v.gsettings != 'undefined' && v.gsettings) ? $.parseJSON(v.gsettings) : {},
7104						        img_path = (typeof vgsettings['storage'] != 'undefined') ? vgsettings['storage'] : _this.b.RESOURCE + '/' + _this.b.SID + '/',
7105						        img_original = (typeof vgsettings['storage'] != 'undefined') ? img_path + '1920/' : img_path;
7106
7107							var src = getServeImage(v.image,val.folder,img_path),
7108								src_s0 = getServeImage(v.image,'0',img_path);
7109							if($(c).find('img').length > 0) $(c).find('img').attr('src',src);
7110							ensureGalleryResponsiveImageClass($(c));
7111							if($(c).find('.g-img').length > 0) $(c).find('.g-img').css('background-image', 'url('+src+')');
7112							if(checkGallerySVG) {
7113								var gimgSVG = $(c).find('.gimg-svg-wrap svg');
7114								gimgSVG.find('pattern').attr('id','gimgSvg_'+val.elname+'_'+item_index);
7115								gimgSVG.find('image').attr('xlink:href', src);
7116								gimgSVG.find('polygon, path').attr('fill', 'url(#gimgSvg_'+val.elname+'_'+item_index+')');
7117							}
7118							
7119							var glink = (typeof vgsettings['glink'] != 'undefined' && vgsettings['glink']) ? vgsettings['glink'] : '',
7120								glink_target = (typeof vgsettings['glink_target'] != 'undefined' && vgsettings['glink_target']) ? vgsettings['glink_target'] : '';
7121
7122							if(glink) {
7123								if(glink.match(/^\@/g) !== null) {															// link-type: link-bookmark ==> a[attr-bookmark]
7124									var bookmark_seq = glink.replace(/^\@/g,'');
7125									if(typeof _this.b.SETTINGS.blockBookmarkList == 'undefined' || typeof _this.b.SETTINGS.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
7126										glink = '';
7127										glink_target = '';
7128									}
7129								} else if(glink.match(/^flink\@[0-9]/gi) !== null) {										// link-type: link-file     ==> a[attr-flink]
7130									glink_target = '';
7131									} else if(isRenderMenuPageLink(glink, _this.b.MENULIST)) {	// link-type: link-menu     ==> a[data-user-link]
7132								} else {																					// link-type: link-out      ==> a[attr-link]
7133									if(checkBase64Encode(glink)) glink = Base64.decode(glink);
7134								}
7135							}
7136
7137							$(c).find('a').removeAttr('data-gallery').removeAttr('data-user-link').removeAttr('attr-bookmark').removeAttr('attr-link').removeAttr('attr-flink');
7138							var gallery_page_chmod = g_settings && g_settings.gallery_page_chmod || null;
7139							var umgrade = property && property.UMGRADE ? (property.UMGRADE.seq || property.UMGRADE.grade_id || null) : null;
7140							if (typeof gallery_page_chmod === 'string') {
7141								try { gallery_page_chmod = JSON.parse(gallery_page_chmod); }
7142								catch (e) { gallery_page_chmod = gallery_page_chmod ? gallery_page_chmod.split(',') : []; }
7143							}
7144							gallery_page_chmod = $.isArray(gallery_page_chmod) ? $.map(gallery_page_chmod, function(v) { return String(v); }) : [];
7145							umgrade = (umgrade !== null && typeof umgrade != 'undefined') ? String(umgrade) : null;
7146							$(c).removeClass('noneShoppingGrade').removeAttr('data-shopping-grade-msg');
7147							if (isShoppingGradePriceHidden(v) && property['SITEUM'] >= 1) {
7148								$(c).addClass('gallery-item').addClass('nonePrice');
7149								$(c).find('a').attr('href', '#');
7150							} else {
7151								if(isShoppingGradeBlocked(v, g_settings, property)) {
7152									$(c).addClass('gallery-item').addClass('noneShoppingGrade');
7153									$(c).attr('data-shopping-grade-msg', getShoppingGradeBlockedMessage(v));
7154									$(c).find('a').attr('href', '#');
7155								} else if(glink) {
7156									var glink_val = makeLinkUrl(glink, b.ONE, b.VIEW);
7157									$(c).find('a').attr('href',glink_val);
7158
7159									if(glink.match(/^\@/g)) {
7160										$(c).find('a').attr('attr-bookmark',glink.replace(/^\@/g,''));
7161									} else if(glink.match(/^flink\@[0-9]/g)) {
7162										$(c).find('a').attr('attr-flink',glink.replace(/^flink\@/g,''));
7163									// IE ERROR_includes__H.20210603
7164									// } else if(_this.b.MENULIST.includes(glink.replace(/ /g,'-'))) {
7165										} else if(isRenderMenuPageLink(glink, _this.b.MENULIST)) {
7166										$(c).find('a').attr('data-user-link',glink_val);
7167									} else {
7168										$(c).find('a').attr('attr-link',glink);
7169									}
7170                                } else {
7171									if (val.mode == 'gallery') {
7172										src_s0 = src_s0 + '?gpos='+v.pos;
7173
7174										$(c).find('a').attr('href', src_s0);
7175										$(c).find('a').attr('data-gallery', '#gframe-' + val.seq);
7176									} else {
7177										if(val.seq == 'all_products') {
7178											$(c).find('a').attr('href', v.product_url);
7179											$(c).removeClass('nonePrice');
7180										} else {
7181											if(_this.b.LUX) $(c).find('a').attr('href', ((_this.b.URL=='/') ? '' : _this.b.URL) + '/_product/' + v.seq);
7182											else $(c).find('a').attr('href', ((_this.b.URL=='/') ? '' : _this.b.URL) + '/' + _this.b.PAGE + '/view/' + v.seq);
7183			
7184											// $(c).find('a').attr('href', ((b.URL=='/') ? '' : b.URL) + '/' + b.PAGE + '/view/' + v.seq);
7185										}
7186									}
7187	                            }
7188	                        }
7189
7190		                    if(glink_target == '_blank') $(c).find('a').attr('target','_blank');
7191		                    else $(c).find('a').removeAttr('target');
7192
7193							$(c).find('.non_text').removeClass('non_text');
7194							
7195							if(mode != 'shopping') {
7196								if(v.title.length==0) $(c).find('.figure.title').removeClass('non_text').addClass('non_text');
7197								if(v.caption.length==0) $(c).find('.figure.caption').removeClass('non_text').addClass('non_text');
7198							}
7199
7200							if(v.title.length==0) v.title = $.lang[block_lang]['editor.block.gallery.sample.title'];
7201							if(v.caption.length==0) v.caption = $.lang[block_lang]['editor.block.gallery.sample.caption'];
7202
7203							if(checkGFrameTitleOFF || !isTitle) $(c).find('a').attr('data-title', '');
7204							else $(c).find('a').attr('data-title', v.title);
7205
7206							if(mode != 'shopping' && isCaption && $(c).find('p.figure.caption').length == 0) {
7207								var $captionParent = ($(c).find('.fig_price').length > 0) ? $(c).find('.fig_price').first() : $(c).find('figcaption').first(),
7208									captionClass = 'figure caption';
7209								if($captionParent.length > 0) $captionParent.prepend('<p class="' + captionClass + '"></p>');
7210							}
7211
7212		                    // caption
7213		                    var ftitle = $(c).find('h5.figure'),
7214		                        fcaption = $(c).find('p.figure').not('.comment'),
7215		                        fdatetime = $(c).find('.figure.datetime'),
7216		                        fhashtag = $(c).find('.figure.hashtag'),
7217		                        fbrand = $(c).find('.figure.brand'),
7218		                        fprice = $(c).find('.figure.price'),
7219								freview = $(c).find('.figure.review'),
7220								fcomment = $(c).find('.figure.comment'),
7221								flike = $(c).find('.figure.like'),
7222								fbasket = $(c).find('.figure.basket');
7223
7224		                    $(c).find('figcaption').removeClass('hide');
7225							if(v.title || v.caption) {
7226								var gallery_caption = v.caption;
7227								gallery_caption = gallery_caption.replace(/\n/g,'<br />');
7228
7229								ftitle.html(v.title);
7230								fcaption.html(gallery_caption);
7231								if(mode != 'shopping' && !isCaption) $(c).find('p.figure.caption').remove();
7232								if(fdatetime.length > 0) fdatetime.text(v.datetime);
7233								if(fhashtag.length > 0) fhashtag.text(v.hashtag);
7234							}
7235							
7236	                        if(g_number) {
7237	                            var g_index = String(item_index + 1),
7238	                                g_num = g_index.padStart(g_number, '0');
7239	                            $(c).find('.figure.number').text(g_num);
7240	                        }
7241
7242							if(fbrand.length > 0) {
7243								var fbrand_name = (typeof v.brand_name != 'undefined' && v.brand_name) ? v.brand_name : '';
7244								fbrand.html(v.brand_name);
7245							}
7246
7247							if(mode == 'shopping' || id == 'all_products') {
7248								fcomment.addClass('hide');
7249								flike.addClass('hide');
7250								
7251								v.price = parseFloat(v.price);
7252								v.sale = parseFloat(v.sale);
7253								var productGradeOnOff = getShoppingGradeProductGradeOnOff(v);
7254								$(c).attr('data-editor-grade-price-enabled', productGradeOnOff).attr('data-config-grade-price-enabled', productGradeOnOff);
7255								var checkPriceHidden = isShoppingGradePriceHidden(v),
7256									base_gallery_price = (v.price && !checkPriceHidden) ? v.price : 0,
7257									base_gallery_sale_price = (typeof v.sale != 'undefined' && v.sale > 0 && v.sale > v.price && !checkPriceHidden) ? v.sale : 0,
7258									gallery_price = base_gallery_price,
7259									gallery_sale_price = base_gallery_sale_price,
7260									gallery_sale_per = (typeof v.sale_per != 'undefined' && v.sale_per && !checkPriceHidden) ? v.sale_per+'%' : '',
7261									grade_price_display = g_settings.grade_price_display == 'ON',
7262									grade_discount_grade = getShoppingGradePreviewDiscountGrade(data.grade),
7263									grade_discount_applied = false,
7264									grade_gallery_price = 0,
7265									product_soldout = '품절',
7266									product_no_sale = (typeof g_settings.sh_soldout == 'string') ? g_settings.sh_soldout : '구매불가',
7267									product_status = '';
7268								if (
7269									!checkPriceHidden &&
7270									isShoppingGradeProductGradePriceEnabled(v)
7271								) {
7272									grade_gallery_price = calcShoppingGradeDisplayPrice(base_gallery_price, grade_discount_grade);
7273									grade_discount_applied = grade_gallery_price !== null;
7274								}
7275								if(v.status == 'off' && !checkPriceHidden) {
7276									product_status = '<span class="cl-sh-soldout">' + product_no_sale + '</span>';
7277								} else if(v.quantity_on == 'on' && v.quantity < 1 && !checkPriceHidden) {
7278									product_status = '<span class="cl-sh-soldout">' + product_soldout + '</span>';
7279								}
7280
7281								$(c).find('.cl-sh-soldout').remove();
7282								if(product_status != '') $(c).attr('data-soldout',true);
7283								else $(c).removeAttr('data-soldout');
7284
7285								$(c).find('.product-badge').remove();
7286								product_status += drawBadgeList(v.use_badge, data.badge_settings);
7287
7288								$(c).find('.cl-sh-limit').remove();
7289								if(v.status == 'lim') {
7290                                    if(v.sale_now == false) {
7291                                        var product_limit = '<p class="cl-sh-limit">상품 구매 가능 기간이 아닙니다.</p>';
7292			                            if(freview.length > 0) {
7293			                                freview.after(product_limit);
7294			                            } else {
7295			                                $(c).find('figcaption:not(.top) .figure:last-child').after(product_limit);
7296			                            }
7297                                    }
7298                                }
7299
7300								if($(c).find('ul.figure.price').length > 0) {
7301									// var price_off = (v.sale_price > 0 && v.sale_price > v.price) ? 100 - Math.floor((v.price / v.sale_price) * 100) : 0,
7302	                                //     off_str = (price_off > 0) ? price_off + '% ' : ''
7303									var off_str = (v.sale_rate > 0) ? v.sale_rate + '% ' : '';
7304									if(!_this.b.LUX) off_str = gallery_sale_per;
7305									if(!off_str && gallery_sale_price > 0 && gallery_price > 0 && gallery_price < gallery_sale_price) {
7306										var price_off = Math.round(((gallery_sale_price - gallery_price) / gallery_sale_price) * 100);
7307										off_str = (price_off > 0) ? price_off + '% ' : '';
7308									}
7309									//Ver02
7310									if(!checkPriceHidden) {
7311										var $priceWrap = $(c).find('ul.figure.price'),
7312											$priceVal = $priceWrap.find('.price-val'),
7313											$priceSale = $priceWrap.find('.price-sale'),
7314											$priceSalePer = $priceWrap.find('.price-sale-per');
7315										$priceWrap.find('.sp-price, .grade-discount-price').remove();
7316										if($priceSale.length >
7316 0 && $priceSalePer.length == 0) {
7317											$priceSale.after('<li class="price-sale-per hide"></li>');
7318											$priceSalePer = $priceWrap.find('.price-sale-per');
7319										}
7320										$priceWrap.css({display:'', flexDirection:'', alignItems:''});
7321										$priceVal.css({order:'', display:''});
7322										$priceSale.css({order:'', display:'', marginRight:''});
7323										$priceSalePer.css({order:'', display:'', marginLeft:'', marginTop:''});
7324											$priceVal.html('₩' + gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,','));
7325										$priceVal.removeClass('hide');
7326
7327										if(gallery_sale_price > 0 && gallery_price  < gallery_sale_price) {
7328											$priceSale.html('₩' + gallery_sale_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,','));
7329												$priceSalePer.html(off_str);
7330											$priceSale.removeClass('hide');
7331												$priceSalePer.removeClass('hide');
7332											if(!grade_discount_applied && _this.b.LUX && (v.hashtag).indexOf('특가세일') > -1 && $(c).find('ul.figure.price .sp-price').length == 0) {
7333												$(c).find('ul.figure.price .price-sale').after('<li class="sp-price">특가세일</li>');
7334											}
7335										} else {
7336											$priceSale.addClass('hide').html('');
7337											$priceSalePer.addClass('hide').html('');
7338
7339										}
7340										
7341                                        if(grade_price_display && grade_discount_applied) {
7342                                            $priceWrap.append('<li class="grade-discount-price"><span class="grade-discount-price-value">₩' + grade_gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,',') + '</span><span class="grade-discount-price-label">나의 할인가</span></li>');
7343                                        }
7344
7345                                        $(c).find('ul.figure.price .price-unit-pricing').remove();
7346                                        if(v.product_unit_str) {
7347                                            $(c).find('ul.figure.price').append(`<li class="price-unit-pricing">${v.product_unit_str}</li>`); // 단위당 가격
7348                                        }
7349									} else {
7350                                        $(c).find('ul.figure.price .price-val').html('₩0');
7351                                        $(c).find('ul.figure.price .price-val').addClass('hide');
7352									}
7353									if(id == 'all_products' && checkPriceHidden) $(c).find('ul.figure.price').html('');
7354									if(product_status) $(c).find('ul.figure.price').append('<li>'+product_status+'</li>');
7355
7356									var badge_size = getBadgeSize(data.badge_settings);
7357									$(c).find('.cl-sh-soldout').removeClass('badge-small badge-medium badge-large');
7358									$(c).find('.cl-sh-limit').removeClass('badge-small badge-medium badge-large');
7359									if(badge_size) {
7360										$(c).find('.cl-sh-soldout').addClass(badge_size);
7361										$(c).find('.cl-sh-limit').addClass(badge_size);
7362									}
7363								} else {
7364									//Ver01
7365									if(fprice.length == 0) fprice = fcaption;
7366
7367									if(checkPriceHidden) fprice.html('');
7368									else fprice.html('<span class="figure-krw">₩</span>' + gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,',') + product_status);
7369								}
7370
7371								if($(c).find('ul.figure.review').length > 0) {
7372									var gallery_review = (v.review_onoff && v.review_cnt) ? v.review_cnt : 0;
7373									if(gallery_review > 0) {
7374										$(c).find('ul.figure.review, ul.figure.review li').removeClass('hide');
7375										$(c).find('ul.figure.review .figure-review-cnt').html(gallery_review);
7376										$(c).find('ul.figure.review .figure-review-score').html(v.review_score);
7377									} else {
7378										$(c).find('ul.figure.review, ul.figure.review li').addClass('hide');
7379										$(c).find('ul.figure.review .figure-review-cnt, ul.figure.review .figure-review-score').html('');
7380									}
7381								}
7382
7383								if(fbasket.length > 0) {
7384									var checkOldBlock = ($(c).find('.figure.basket[data-oldver="true"]').length > 0) ? true : false,
7385										checkOldverBasket = (typeof g_settings.field_oldver != 'undefined' && g_settings.field_oldver && g_settings.field_oldver.indexOf('basket') > -1) ? true : false,
7386										checkDisabledBasket = (typeof g_settings.field_disable != 'undefined' && g_settings.field_disable && g_settings.field_disable.indexOf('basket') > -1) ? true : false;
7387									if(v.basket_off || v.shopping_grade_hidden == 'ON') fbasket.addClass('cannotby hide');
7388									else if(id == 'all_products') fbasket.removeClass('hide');
7389									else if(checkDisabledBasket || (!checkDisabledBasket && checkOldBlock && !checkOldverBasket)) fbasket.addClass('hide');
7390									else if(property.VALIDTYPE != 'SM') fbasket.addClass('hide');
7391									else fbasket.removeClass('hide');
7392								}
7393
7394
7395							} else {
7396								fbrand.addClass('hide');
7397								fprice.addClass('hide');
7398								freview.addClass('hide')
7399								fbasket.addClass('hide');
7400
7401								if ( checkUseComment 
7402									&& g_settings.comment_display == 'ON'
7403									&& !(g_settings.field_disable !== undefined && g_settings.field_disable.indexOf('comment') > -1)
7404									&& fcomment.length > 0
7405									&& (typeof v.comment_cnt != 'undefined' && v.comment_cnt > 0)
7406								) {
7407									fcomment.removeClass('hide');
7408									fcomment.find('.figure-comment-cnt').html(v.comment_cnt);
7409								} else {
7410									fcomment.addClass('hide');
7411									fcomment.find('.figure-comment-cnt').empty();
7412								}
7413	
7414								if ( checkUseLike 
7415									&& (g_settings.like_display !== undefined && g_settings.like_display != 'N')
7416									&& !(g_settings.field_disable !== undefined && g_settings.field_disable.indexOf('like') > -1)
7417									&& flike.length > 0
7418								) {
7419									flike.removeClass('hide').find('.figure-like-cnt').html(0);
7420									if(v.like !== undefined) {
7421										flike.find('.figure-like-cnt').html(v.like.cnt);
7422										if (v.like.own && v.like.cnt > 0) flike.attr('data-like', v.seq).addClass('active');
7423									}
7424								} else {
7425									flike.addClass('hide');
7426								}
7427							}
7428
7429                            if(checkUseLike == false) flike.html('');
7430
7431							if(isMasonry) {
7432								gallery_item = gallery_item + $(c)[0].outerHTML;
7433							} else {
7434								if(checkLoadmoreInLoop) $gLoop.find('.loadmore-wrap').before($(c)[0].outerHTML);
7435								else $gLoop.append($(c)[0].outerHTML);
7436							}
7437		                });
7438		            }
7439		        });
7440				changeBrokenImages($galleryEL);
7441
7442				if(isMasonry) {
7443					$('.gallery-loadmore[data-id="' + id + '"]').before('<div class="gallery-loading-status"><div class="loading-dots"></div></div>');
7444					showHideGalleryField($galleryEL,g_settings);
7445					reloadBlockMasonry('add',$galleryEL,$(gallery_item));
7446				} else {
7447					showHideGalleryField($galleryEL,g_settings);
7448				}
7449
7450				var cookie_page = gpage,
7451					new_view = (view > total) ? total : view,
7452					cookie_view = ( (cookie_page*new_view) > total ) ? total : cookie_page*new_view;
7453
7454				$galleryEL.find('.display').text(cookie_view);
7455
7456				var $glmBtnWrap = $galleryELLoadmore.closest('.loadmore-wrap'),
7457					$glmBtn = $galleryEL.find('.loadmore-wrap .gallery-loadmore'),
7458					checkLoadmore = (total > view && total > cookie_view) ? true : false;
7459				
7460				if($glmBtnWrap.length == 0) {
7461					// gallery loadmore btn - default (ver1)
7462					if(checkLoadmore) $galleryELLoadmore.attr('data-page', cookie_page + 1);
7463					else $galleryELLoadmore.remove();
7464				} else {
7465					// gallery loadmore btn - custom (ver2)
7466					if(checkLoadmore) {
7467						$glmBtn.attr('data-page', cookie_page + 1);
7468						$glmBtnWrap.removeClass('hide').fadeIn();
7469					} else {
7470						$glmBtnWrap.fadeOut().addClass('hide');
7471						$glmBtn.removeAttr('data-loadmore').removeAttr('data-id').removeAttr('data-total').removeAttr('data-page').removeAttr('data-view').removeAttr('data-folder').removeAttr('data-mode').removeClass('masonry-layout');
7472						$glmBtn.find('.display .view').text('0');
7473						$glmBtn.find('.display .total').text('0');
7474					}
7475				}
7476
7477				if($galleryEL.has('input.gjs').length) setGalleryJS('add-loop',$galleryEL);
7478				
7479				if($galleryEL.find('*[data-direffect="true"]').length > 0 ) {
7480					setTimeout(function() {
7481						$galleryEL.find('.grid').each(function() {
7482							$(this).hoverdir();
7483						});
7484					}, 400);
7485				}
7486			}
7487		});
7488
7489		$('.gallery-loadmore, .data-feed-load-more').live('touchstart', function (e) {
7490			var g_color = $(this).css('color'),
7491				g_bgcolor = $(this).css('background-color'),
7492				g_bdcolor = $(this).css('border-color');
7493
7494			if(isMobile()) {
7495				$(this).css('color', g_color);
7496				$(this).css('background-color', g_bgcolor);
7497				$(this).css('border-color', g_bdcolor);
7498			}
7499		});
7500		
7501		$('.gallery-item a[title]').live('mouseenter', function () {
7502		    $(this).tooltip('destroy');
7503		});
7504
7505		$('.gallery-item a:not([attr-flink])').live({
7506			click : function(e) {
7507		    	e.preventDefault();
7508				if($(e.target).is('.figure.basket') || $(e.target).is('.basket-btn')) return false;
7509
7510				var loc = $(this).attr('href'),
7511					mode = $(this).attr('data-gallery'),
7512					menu_link = $(this).attr('data-user-link'),
7513					bookmark = $(this).attr('attr-bookmark'),
7514					blank = $(this).attr('target'),
7515					user_link = $(this).attr('attr-link');
7516
7517				if( (typeof mode!='undefined' && mode.length>0) ||
7518					(typeof menu_link!='undefined' && menu_link.length>0) ||
7519					// (typeof user_link!='undefined' && user_link.length>0) ||
7520					(typeof bookmark!='undefined' && bookmark.length>0) 
7521				) return;
7522
7523				if(typeof blank!='undefined' && blank.length) {
7524					var url = (typeof user_link != 'undefined' && user_link.match('^(tel:|mailto:|sms:)') === null) ? makeLinkUrl(user_link, b.ONE, b.VIEW) : loc;
7525					var openNewWindow = window.open(url);
7526				} else {
7527					if(typeof user_link != 'undefined' && user_link) {
7528						location.href=loc;
7529					} else {
7530						var url = new getLocation(loc);
7531						golink(_this,url);
7532					}
7533		    	}
7534
7535		    	// 	uri = (b.PUBLISH) ? loc : loc.replace('/render/',''),
7536		    	// 	attr = $(this).attr('attr-link');
7537
7538		    	// if(typeof attr!='undefined' && attr) return;
7539	    		// _this.history.pushState(null,b.TITLE,(b.PUBLISH) ? '/' : '/render/' + uri);
7540			}
7541		});
7542		$('.gallery-item .figure.like').live('click', function(e){
7543			e.preventDefault();
7544			return false;
7545		});
7546		$('.gallery-item .figure.basket, .pitem .basket-box').live('click', function(e) {
7547			e.preventDefault();
7548			var checkPsearch = ($(this).closest('.pitem').length > 0) ? true : false;
7549			if(b.PUBLISH) {
7550				if(!checkPsearch && $(this).closest('.gallery-item').hasClass('nonePrice')) {
7551					$(this).closest('.nonePrice').click();
7552					return false;
7553				}
7554
7555				var tmp_pid = (checkPsearch) ? $(this).closest('.pitem').attr('data-pid') : $(this).closest('.element').attr('data-id'),
7556					tmp_seq = (checkPsearch) ? $(this).closest('.pitem').attr('data-gid') : $(this).closest('.gallery-item').attr('data-seq');
7557				$.quickbasket.init(b.SID,tmp_pid,tmp_seq);
7558			} else {
7559				$(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['manager.check.no-support.render-mode'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0');
7560				return false;
7561			}
7562		});
7563
7564		// tab-box left-right button event
7565		$(document).on('click', '.left-arrow .arrow:not(.hide) .before', function(e){ 
7566			var horizontal = $(this).closest('.tabs').attr('tab-horizontal'),
7567				motion = Number($(this).closest('.tabs').attr('tab-motion')),
7568				len = $(this).closest('.container').find('.tab-box .tab:not(.hover)').length,
7569				motion_style = $(this).closest('.tabs').attr('tab-motion-style'),
7570				tab_counted = $(this).closest('.tabs').attr('tab-count'),
7571				mobile_tab_count = $(this).closest('.tabs').attr('mobile-tab-count'),
7572				tab_interval_w = ($(window).width() < 768 && Number($(this).closest('.tabs').attr('tab-interval-w')) > 8) ? Number($(this).closest('.tabs').attr('tab-interval-w')) * 0.8 : $(this).closest('.tabs').attr('tab-interval-w'),
7573				w = $(window).width(),
7574				tab_count = (w < 991) ? ((typeof mobile_tab_count != 'undefined' && mobile_tab_count) ? mobile_tab_count : ((tab_counted > 4) ? 4 : tab_counted)) : $(this).closest('.tabs').attr('tab-count'),
7575				tab_case = $(this).closest('.tabs').attr('data-case');
7576			
7577			if(!$(this).closest('.tabs').attr('tab-motion') || $(this).closest('.tabs').attr('tab-motion') == 'undefined') return false;
7578	
7579			if(horizontal == 1) { // 가로형
7580				var	tab_each = Number($(this).closest('.container').find('.tab-box .tab:not(.hover)').outerWidth()) + Number(tab_interval_w),
7581					max_width = Number($(this).closest('.container').find('.tab-box .tab:not(.hover)').outerWidth(true)) * len,
7582					tab_width = (Number($(this).closest('.container').find('.tab-box .tab:not(.hover)').outerWidth()) + Number(tab_interval_w)) * tab_count,
7583					length = max_width / tab_width,
7584					mo = Number(len) - tab_count;
7585				// console.log('motion:' + motion + ', len: ' + len + ', tab_count: ' + tab_count + ', tab_each: ' + tab_each + ', max_width: ' + max_width + ', tab_width: ' + tab_width + ',length: ' + length + ',mo: ' + mo);
7586			} 
7587	
7588			if(motion_style == 1) { // 한칸씩 이동
7589				motion = motion - 1;
7590				if(motion < 0) motion = 0;
7591				$('.'+$(this).closest('.tabs').attr('data-name')).attr('tab-motion', motion);
7592	
7593				tabMotion($(this).closest('.tabs').attr('data-name'), motion, tab_each, len, motion_style, tab_count, tab_case, tab_counted);
7594	
7595			} else { // 한페이지씩 이동
7596				motion = motion - 1;
7597				if(motion < 0) motion = 0;
7598				$('.'+$(this).closest('.tabs').attr('data-name')).attr('tab-motion', motion);
7599	
7600				tabMotion($(this).closest('.tabs').attr('data-name'), motion, tab_width, length, motion_style, tab_count, tab_case, tab_counted);
7601			}
7602			
7603		});
7604		$(document).on('click', '.right-arrow .arrow:not(.hide) .after', function(e){ 
7605			var horizontal = $(this).closest('.tabs').attr('tab-horizontal'),
7606				motion = Number($(this).closest('.tabs').attr('tab-motion')),
7607				len = $(this).closest('.container').find('.tab-box .tab:not(.hover)').length,
7608				motion_style = $(this).closest('.tabs').attr('tab-motion-style'),
7609				tab_counted = $(this).closest('.tabs').attr('tab-count'),
7610				mobile_tab_count = $(this).closest('.tabs').attr('mobile-tab-count'),
7611				tab_interval_w = ($(window).width() < 768 && Number($(this).closest('.tabs').attr('tab-interval-w')) > 8) ? Number($(this).closest('.tabs').attr('tab-interval-w')) * 0.8 : $(this).closest('.tabs').attr('tab-interval-w'),
7612				w = $(window).width(),
7613				tab_count = (w < 991) ? ((typeof mobile_tab_count != 'undefined' && mobile_tab_count) ? mobile_tab_count : ((tab_counted > 4) ? 4 : tab_counted)) : $(this).closest('.tabs').attr('tab-count'),
7614				tab_case = $(this).closest('.tabs').attr('data-case');
7615			
7616			if(!$(this).closest('.tabs').attr('tab-motion') || $(this).closest('.tabs').attr('tab-motion') == 'undefined') return false;
7617	
7618			if(horizontal == 1) { // 가로형
7619				var	tab_each = Number($(this).closest('.container').find('.tab-box .tab:not(.hover)').outerWidth()) + Number(tab_interval_w),
7620					max_width = Number($(this).closest('.container').find('.tab-box .tab:not(.hover)').outerWidth(true)) * len,
7621					tab_width = (Number($(this).closest('.container').find('.tab-box .tab:not(.hover)').outerWidth()) + Number(tab_interval_w)) * tab_count,
7622					length = max_width / tab_width,
7623					mo = Number(len) - tab_count;
7624				// console.log('motion:' + motion + ', len: ' + len + ', tab_count: ' + tab_count + ', tab_each: ' + tab_each + ', max_width: ' + max_width + ', tab_width: ' + tab_width + ',length: ' + length + ',mo: ' + mo);
7625			} 
7626	
7627			if(motion_style == 1) { // 한칸씩 이동
7628				motion = motion + 1;
7629				if(motion > mo) motion = mo;
7630				$('.'+$(this).closest('.tabs').attr('data-name')).attr('tab-motion', motion);
7631	
7632				tabMotion($(this).closest('.tabs').attr('data-name'), motion, tab_each, len, motion_style, tab_count, tab_case, tab_counted);
7633	
7634			} else { // 한페이지씩 이동
7635				motion = motion + 1;
7636				if(motion >= length) motion = Math.ceil(length) - 1;
7637				$('.'+$(this).closest('.tabs').attr('data-name')).attr('tab-motion', motion);
7638	
7639				tabMotion($(this).closest('.tabs').attr('data-name'), motion, tab_width, length, motion_style, tab_count, tab_case, tab_counted);
7640			}
7641		});
7642		$(document).on('click', '.tab-box .tab', function(){
7643			var w = $(document).outerWidth(),
7644				horizontal = $(this).closest('.tabs').attr('tab-horizontal');
7645			if(w < 767 && $(this).find('.tab-editor').hasClass('active')) {
7646				$(this).find('.tab-editor').removeClass('active');
7647			} else {
7648				var editor = $(this).index() + 1,
7649					order = $(this).attr('data-order');
7650					// num = $('.tab-editor.active.t'+order).outerHeight();
7651	
7652				$(this).siblings().removeClass('active');
7653				$(this).addClass('active');
7654	
7655				if(horizontal == 0) { // 세로형
7656					$(this).closest('.tab-box').find('.tab .tab-editor').removeClass('active');
7657					$(this).closest('.tab-box').find('.tab .tab-editor.tabs'+order).addClass('active');
7658				} else { // 가로형
7659					$(this).closest('.tab-width').siblings('.editor-box').children('.tab-editor').removeClass('active');
7660					$(this).closest('.tab-width').siblings('.editor-box').children('.tab-editor.tabs'+order).addClass('active');
7661				}
7662			}
7663		});
7664
7665		$('.tab-wrapper .tab-box .tab').live({
7666			click: function() {
7667				$(this).removeClass('hover');
7668			},
7669			mouseover: function() {
7670				$('.tab-wrapper .tab-box .tab:not(.hide)').removeClass('hover');
7671				if(!$(this).hasClass('active'))	$(this).addClass('hover');
7672			},
7673			mouseout: function() {
7674				$('.tab-wrapper .tab-box .tab:not(.hide)').removeClass('hover');
7675			}
7676		});
7677
7678		$('.userELallProducts .cl-gsort-list li').live({
7679			mouseover: function() {
7680				$(this).addClass('hover');
7681				$(this).siblings().removeClass('hover');
7682			},
7683			mouseout: function() {
7684				$('.userELallProducts .cl-gsort-list li').removeClass('hover');
7685			}
7686		});
7687
7688		//calendar 블럭
7689		let currentDate = new Date();
7690		let currentEvent = null;
7691		let lastEventsList = null;
7692		let lastEventsWeekday = null;
7693		let calendarElsettings = new Map();
7694		let googleColor = new Map();
7695		const monthCache = new Map();
7696		const inflight    = new Map();
7697
7698		//calendar textarea//
7699		const SEL = '.calendar-modal-body .modal-field.content textarea';
7700		function getMax() {
7701			const w = window.innerWidth || document.documentElement.clientWidth;
7702			if (w >= 1200) return 500;   // 1200px 이상
7703			if (w >= 768)  return 400;   // 1199~768px
7704			return 320;                  // 767px 이하
7705		}
7706		function fit($ta) {
7707			const el = $ta[0];
7708			const min = parseFloat(getComputedStyle(el).minHeight) || 120;
7709			const MAX = getMax();
7710
7711			$ta.css('height', 'auto');
7712
7713			const sh = el.scrollHeight; 
7714			const h  = Math.max(min, Math.min(sh, MAX));
7715
7716			$ta.css({
7717				height: h + 'px',
7718				overflowY: sh > MAX ? 'auto' : 'hidden'
7719			});
7720		}
7721		function refitAll() {
7722			$(SEL).filter(':visible').each(function () {
7723				fit($(this));
7724			});
7725		}
7726		function debounce(fn, wait = 120) {
7727			let t; 
7728			return function () {
7729				clearTimeout(t);
7730				t = setTimeout(() => fn.apply(this, arguments), wait);
7731			};
7732		}
7733		let lastMax = getMax();
7734		$(window).on('resize.autogrow orientationchange.autogrow', debounce(function () {
7735			const curMax = getMax();
7736			if (curMax !== lastMax) {
7737				lastMax = curMax;
7738				refitAll();
7739			}
7740		}));
7741		$(document).on('input change', SEL, function () {
7742			fit($(this));
7743		});
7744		////////////////////////////////////////////////////////////////////////////////////
7745
7746		$.cl_calendar = {
7747			active : '',
7748			events : [],
7749			instances : {},
7750			// currentDate : new Date(),
7751			init : function(sid, pid, yearMonth, c) { 
7752				if(typeof sid == 'undefined' || typeof pid == 'undefined') {
7753					alert('Undefined SID,PID');
7754					return false;
7755				}
7756
7757				$(`[data-type="calendar"][data-id="${pid}"]`).removeClass('_calendar'); //_calendar가 html붙어버릴경우
7758
7759				// pid 별로 관리되는 인스턴스 생성
7760				if(!$.cl_calendar.instances[pid]) {
7761					$.cl_calendar.instances[pid] = {
7762						currentDate: new Date(),
7763						events: []
7764					};
7765				}
7766				$.cl_calendar.instances[pid].config = c;
7767
7768				var instance = $.cl_calendar.instances[pid];
7769
7770				if(typeof yearMonth !== 'undefined' && yearMonth != '') {
7771					var parts = yearMonth.split('-');
7772					instance.currentDate = new Date(parseInt(parts[0]), parseInt(parts[1]) - 1, 1);
7773				}
7774				var data_type = ($('.userEL'+pid).attr('data-modoo-type')) ? $('.userEL'+pid).attr('data-modoo-type') : '';
7775				var y = instance.currentDate.getFullYear();
7776				var m = String(instance.currentDate.getMonth() + 1).padStart(2, '0');
7777				var ym = (yearMonth && yearMonth !== '') ? yearMonth : (y + '-' + m);
7778
7779				if(data_type != '') {
7780					$.ajax({
7781						url: '/template/get_calendar',
7782						data: { sid: sid, pid: pid, yearMonth: ym, data_type: data_type },
7783						type: 'POST',
7784						dataType: 'json',
7785						success: function (data) {
7786							checkError(data);
7787							var inst = $.cl_calendar.instances[pid];
7788
7789							var dataArr = Array.isArray(data) ? data : [];
7790
7791							inst.events = dataArr;
7792							$.cl_calendar.draw(pid, data_type, c);
7793
7794							// --- 모바일 이벤트 렌더링 (선택 월 기준) ---
7795							var $root = $('.element[data-id="' + pid + '"]');
7796							if ($root.find('.mobile-events').length === 0) {
7797								$root.find('.notice').before('<div class="mobile-events"></div>');
7798							}
7799							var $mobile = $root.find('.mobile-events').empty();
7800
7801							var currentYear = inst.currentDate.getFullYear();
7802							var currentMonth = inst.currentDate.getMonth() + 1;
7803
7804							var countThisMonth = 0;
7805							var eventMap = {};
7806
7807							$.each(dataArr, function (i, v) {
7808								var d = new Date(v.s_date);
7809								var year = d.getFullYear();
7810								var month = d.getMonth() + 1;
7811
7812								if (year === currentYear && month === currentMonth) {
7813									countThisMonth++;
7814									var dateKey = v.s_date; // 'YYYY-MM-DD'
7815									var time = (v.fulltime === 'Y') ? '종일' : (v.s_time + ' ~ ' + v.e_time);
7816									if (!eventMap[dateKey]) eventMap[dateKey] = [];
7817									eventMap[dateKey].push(
7818										'<div class="event-memo"><span class="event-time">' + time + '</span>' + (v.memo || '') + '</div>'
7819									);
7820								}
7821							});
7822
7823							var html = '';
7824							if (countThisMonth === 0) {
7825								html += ''
7826								+ '<div class="event-date"></div>'
7827								+ '<div class="event-memo"><span class="event-time noschedule">이번달 일정이 없습니다.</span></div><br>';
7828							} else {
7829								var sortedDates = Object.keys(eventMap).sort();
7830								$.each(sortedDates, function (i, date) {
7831									html += '<div class="event-date">' + date_string(date) + '</div>';
7832									$.each(eventMap[date], function (j, memoHtml) { html += memoHtml; });
7833									html += '<br>';
7834								});
7835							}
7836
7837							$mobile.append(html);
7838						}
7839					});
7840				} else {
7841					var elsettings = JSON.parse(c.elsettings);
7842					instance.readChmod = elsettings.read_chmod;
7843					// instance.canShowAll = calendarShow(elsettings);
7844					calendarElsettings.set(pid, calendarShow(elsettings));
7845					fetchMonth(pid, ym, data_type)
7846						.then(function(evts) {
7847							$.cl_calendar.instances[pid].events = evts || [];
7848							monthCache.set(ym, evts || []);
7849							$.cl_calendar.draw(pid, data_type, c);
7850						}).catch(function() {
7851							$.cl_calendar.draw(pid, data_type, c);
7852						});
7853				}
7854
7855				
7856				
7857			},
7858			draw: function(pid, type, c) {
7859				if(type) {
7860					if (!$.cl_calendar.instances[pid]) {
7861						// console.error(`draw called but instance for pid=${pid} is not initialized yet`);
7862						return;
7863					}
7864					var instance = $.cl_calendar.instances[pid];
7865					const year = instance.currentDate.getFullYear();
7866					const month = instance.currentDate.getMonth();
7867
7868					const firstDay = new Date(year, month, 1);
7869					const lastDay = new Date(year, month + 1, 0);
7870					const firstDayOfWeek = firstDay.getDay();
7871					const prevLastDay = new Date(year, month, 0).getDate();
7872					$('.userEL'+pid+' .days').empty();
7873
7874					for (let i = firstDayOfWeek - 1; i >= 0; i--) {
7875						const day = prevLastDay - i;
7876						const curDate = new Date(year, month - 1, day);
7877						const dateString = formatDate(curDate);
7878						const dayElement = createDayElement(curDate, dateString, true, pid);
7879						$('.userEL'+pid+' .days').append(dayElement);
7880					}
7881
7882					for (let i = 1; i <= lastDay.getDate(); i++) {
7883						const curDate = new Date(year, month, i);
7884						const dateString = formatDate(curDate);
7885						const dayElement = createDayElement(curDate, dateString, false, pid);
7886						$('.userEL'+pid+' .days').append(dayElement);
7887					}
7888
7889					const totalCellsNeeded = Math.ceil((firstDayOfWeek + lastDay.getDate()) / 7) * 7;
7890					const nextMonthschedule = totalCellsNeeded - (firstDayOfWeek + lastDay.getDate());
7891					
7892					for (let i = 1; i <= nextMonthschedule; i++) {
7893						const curDate = new Date(year, month + 1, i);
7894						const dateString = formatDate(curDate);
7895						const dayElement = createDayElement(curDate, dateString, true, pid);
7896						$('.userEL'+pid+' .days').append(dayElement);
7897					}
7898
7899					var data_case = $('.userEL'+pid).attr('data-case'); //calendar1 check
7900					if(data_case == 'calendar1') {
7901						$('.userEL'+pid+' .date_wrap').siblings('.date_bullet').remove();
7902						$('.userEL'+pid+' .date_wrap').remove();
7903						$('.userEL'+pid+' .controls').append('<div class="date_wrap"><a href="javascript:void(0)" class="date _selectedCalendar" data-type="yearMonth" data-val="'+(year+'.'+(month + 1))+'">'+(year+'.'+String(month + 1).padStart(2, "0"))+'</a></div>');
7904					}
7905				} else {
7906					initCalendar(pid, c);
7907				}
7908			},
7909			write: function(dateAttr, el) {
7910				selectedDate = dateAttr;
7911				openEventModal(dateAttr, el);
7912			},
7913			modify: function(dateAttr, el, pid) {
7914				if (!$.cl_calendar.instances[pid]) {
7915					// console.error(`Calendar instance for pid=${pid} is not initialized yet`);
7916					return;
7917				}
7918				selectedDate = dateAttr;
7919				openEventList(dateAttr, $.cl_calendar.instances[pid].events, el);
7920			},
7921			save: function(pid, el) {
7922				el = '.'+el+' ';
7923				const eventId = $(el+'#eventId').val();
7924				const eventSeq = $(el+'#eventSeq').val();
7925				const eventSid = $(el+'#eventSid').val();
7926				const eventFulltime = ($(el+'#eventFulltime').val() != '' && $(el+'#eventFulltime').val() == 'Y') ? 'Y' : 'N';
7927				const eventStartDate = $(el+'#eventStartDate').val();
7928				const eventStartTime = ($(el+'#eventFulltime').val() != '' && $(el+'#eventFulltime').val() == 'Y') ? '' : $(el+'#eventStartTime').val();
7929				const eventEndDate = $(el+'#eventEndDate').val();
7930				const eventEndTime = ($(el+'#eventFulltime').val() != '' && $(el+'#eventFulltime').val() == 'Y') ? '' : $(el+'#eventEndTime').val();
7931				const eventMemo = $(el+'#eventMemo').val();
7932				
7933				// 유효성 검사
7934				if (!eventStartDate || (eventFulltime != 'Y' && !eventStartTime) || !eventEndDate || (eventFulltime != 'Y' && !eventEndTime) || !eventMemo) {
7935					alert('필수 항목을 모두 입력해주세요.');
7936					return;
7937				}
7938				
7939				// 종료일시가 시작일시보다 늦은지 확인
7940				const startDateTime = new Date(`${eventStartDate}T${eventStartTime}`);
7941				const endDateTime = new Date(`${eventEndDate}T${eventEndTime}`);
7942				
7943				if (endDateTime <= startDateTime) {
7944					alert('종료 일시는 시작 일시보다 나중이어야 합니다.');
7945					return;
7946				}
7947				
7948				// 이벤트 객체 생성
7949				const eventData = {
7950					sid: b.SID,
7951					seq: (eventSeq) ? eventSeq : '',
7952					pid: pid,
7953					month: eventStartDate.substring(0, 7),
7954					sdate: eventStartDate,
7955					stime: eventStartTime,
7956					edate: eventEndDate,
7957					etime: eventEndTime,
7958					fulltime: eventFulltime,
7959					notice: '',
7960					memo: eventMemo,
7961					check: 1
7962				};
7963
7964				if(eventData['sid'] == '' || eventData['sid'] == undefined) return false;
7965				
7966				var url = '/template/calendar';
7967				// if(eventSeq) {
7968				// 	url = '/template/modify_calendar';
7969				// } else {
7970				// 	url = '/template/calendar';
7971				// }
7972
7973				var data_type = ($('.userEL'+pid).attr('data-modoo-type')) ? $('.userEL'+pid).attr('data-modoo-type') : '';
7974				$.ajax({
7975					url: url,
7976					data: { data: eventData },
7977					type: 'POST',
7978					dataType: 'json',
7979					success: function(data) {
7980						checkError(data);
7981						$.cl_calendar.instances[pid].events = data || [];
7982						$.cl_calendar.draw(pid, data_type);
7983					},
7984					error: function (xhr, status, error) {
7985						
7986					}
7987				});
7988				
7989				// 폼 초기화
7990				$(el+'#eventForm')[0].reset();
7991				$(el+'#eventId').val('');
7992				$(el+'.modal-schedule').fadeOut(300);
7993			}
7994		}
7995
7996		// 날짜 셀 클릭 이벤트 (동적으로 생성된 요소에 대한 이벤트 처리)
7997		$(document).on('click', '.calendar .day_wrap', function() {
7998			// console.log(1212);
7999			var dateAttr = $(this).data('date'),
8000				isEvent = $(this).find('.event').length,
8001				el = '.' + $(this).closest('.calendar').attr('data-name'),
8002				pid = $(this).closest('.calendar').attr('data-id');
8003
8004			var getYear = currentDate.getFullYear(),
8005				getMonth = String(currentDate.getMonth() + 1).padStart(2, "0"), // getMonth는 0~11이므로 +1
8006				yearMonth = getYear + '-' + getMonth;
8007
8008			if(isEvent > 0) {
8009				var parts = dateAttr.split('-');
8010				var yearMonth = parts[0] + '-' + parts[1];
8011				$.cl_calendar.init(b.SID, pid, yearMonth);
8012				$.cl_calendar.modify(dateAttr, el, pid);
8013			}
8014		});
8015
8016		$(document).on('click', '.calendar ._prev_month_btn', function () {
8017			var pid = $(this).closest('.calendar').attr('data-id');
8018
8019			// 여기!
8020			var instance = $.cl_calendar.instances[pid];
8021			instance.currentDate.setMonth(instance.currentDate.getMonth() - 1);
8022
8023			var getYear = instance.currentDate.getFullYear(),
8024				getMonth = String(instance.currentDate.getMonth() + 1).padStart(2, "0"),
8025				yearMonth = getYear + '-' + getMonth,
8026				ym = getYear + '.' + getMonth;
8027
8028			$(this).siblings('.date_bullet').remove();
8029    		$(this).siblings('.date_wrap').remove();
8030    		$(this).parent('.controls').append('<div class="date_wrap"><a href="javascript:void(0)" class="date _selectedCalendar" data-type="yearMonth" data-val="'+ym+'">'+ym+'</a></div>');
8031
8032			$.cl_calendar.init(b.SID, pid, yearMonth);
8033		});
8034
8035		$(document).on('click', '.calendar ._next_month_btn', function () {
8036			var pid = $(this).closest('.calendar').attr('data-id');
8037
8038			var instance = $.cl_calendar.instances[pid];
8039			instance.currentDate.setMonth(instance.currentDate.getMonth() + 1);
8040
8041			var getYear = instance.currentDate.getFullYear(),
8042				getMonth = String(instance.currentDate.getMonth() + 1).padStart(2, "0"),
8043				yearMonth = getYear + '-' + getMonth,
8044				ym = getYear + '.' + getMonth;
8045
8046			$(this).siblings('.date_bullet').remove();
8047    		$(this).siblings('.date_wrap').remove();
8048    		$(this).parent('.controls').append('<div class="date_wrap"><a href="javascript:void(0)" class="date _selectedCalendar" data-type="yearMonth" data-val="'+ym+'">'+ym+'</a></div>');
8049
8050			$.cl_calendar.init(b.SID, pid, yearMonth);
8051		});
8052
8053		$(document).on('click', '.calendar ._today_btn', function() {
8054			var pid = $(this).closest('.calendar').attr('data-id');
8055			var instance = $.cl_calendar.instances[pid];
8056			instance.currentDate = new Date();
8057
8058			var ym = instance.currentDate.getFullYear() + '.' + String(instance.currentDate.getMonth() + 1).padStart(2, "0");
8059			$(this).parent('.calendar_btn_area').siblings('.date_bullet').remove();
8060			$(this).parent('.calendar_btn_area').siblings('.date_wrap').remove();
8061			$(this).closest('.controls').append('<div class="date_wrap"><a href="javascript:void(0)" class="date _selectedCalendar" data-type="yearMonth" data-val="'+ym+'">'+ym+'</a></div>');
8062			
8063			var yearMonth = instance.currentDate.getFullYear() + '-' + String(instance.currentDate.getMonth() + 1).padStart(2, "0");
8064			$.cl_calendar.init(b.SID, pid, yearMonth);
8065		});
8066
8067		// 모달 닫기 버튼 클릭 이벤트
8068		$(document).on('click','.calendar #cancelBtn, .calendar .modal-close', function() {
8069			closeEventModal();
8070		});
8071
8072		// 모달 외부 클릭 시 닫기
8073		$(document).on('click', '.calendar .modal-schedule', function(e) {
8074			if ($(e.target).hasClass('modal-schedule')) {
8075				closeEventModal();
8076			}
8077		});
8078
8079		$(document).on('click','.calendar .date._selectedCalendar',function(){
8080			var el = '.userEL' + $(this).closest('.calendar').attr('data-id');
8081
8082			// 현재 선택된 년월 추출
8083			var currentYM = $(this).attr('data-val');
8084			var parts = currentYM.split('.');
8085			var selectedYear = parts[0];
8086			var selectedMonth = parts[1].padStart(2, '0');
8087
8088			// 이미 열려있다면 제거
8089			if($('.date_list_area._yearMonthList').length > 0){
8090				$('.date_list_area._yearMonthList').remove();
8091				return;
8092			}
8093
8094			// 왼쪽 연도 리스트
8095			let currentYear = currentDate.getFullYear();
8096			let startYear = currentYear - 8;
8097			let endYear = currentYear + 8;
8098
8099			let years = '';
8100			for(let year = startYear; year <= endYear; year++) {
8101				let isSelected = (year == selectedYear) ? ' selected' : '';
8102				years += `<div class="year_item${isSelected}" data-year="${year}">${year}</div>`;
8103			}
8104
8105			let months = '';
8106			for(let month=1; month<=12; month++){
8107				let mm = month.toString().padStart(2, '0');
8108				let isSelected = (mm == selectedMonth) ? ' selected' : '';
8109				months += `<a href="#" class="month_item${isSelected}" data-month="${mm}" data-year="${selectedYear}">${mm}</a>`;
8110			}
8111
8112			// HTML 동적 삽입
8113			let html = `
8114			<div class="mobile_back"><button class="mobile_close">✕</button></div>
8115			<div class="date_list_area _calendarList _yearMonthList">
8116				<div class="year_month_wrap">
8117					<div class="year_list">${years}</div>
8118					<div class="month_list">${months}</div>
8119				</div>
8120				<div class="calendar_confirm_area">
8121					<button type="button" class="btn_cancel">취소</button>
8122					<button type="button" class="btn_confirm">확인</button>
8123				</div>
8124			</div>`;
8125
8126			$(this).after(html);
8127
8128			// 연도 리스트 스크롤 중앙
8129			var selectedYearEl = $(el+' .year_item.selected')[0];
8130			if(selectedYearEl) {
8131				selectedYearEl.scrollIntoView({block: "center", behavior: "smooth"});
8132			}
8133
8134			// 월 리스트 스크롤 중앙
8135			var selectedMonthEl = $(el+' .month_item.selected')[0];
8136			if(selectedMonthEl) {
8137				selectedMonthEl.scrollIntoView({block: "center", behavior: "smooth"});
8138			}
8139
8140			// 연도 클릭하면 월 리스트 갱신
8141			$(el+' .year_item').on('click', function(){
8142				let selectedYear = $(this).data('year');
8143				$(el+' .year_item').removeClass('selected');
8144				$(this).addClass('selected');
8145
8146				let monthsHtml = '';
8147				for(let month=1; month<=12; month++){
8148					let mm = month.toString().padStart(2, '0');
8149					monthsHtml += `<a href="#" class="month_item" data-month="${mm}" data-year="${selectedYear}">${mm}</a>`;
8150				}
8151				$(el+' .month_list').html(monthsHtml);
8152
8153				// 월 클릭 다시 바인딩
8154				bindMonthClick();
8155			});
8156
8157			function bindMonthClick(){
8158				$(el+' .month_item').on('click', function(e){
8159					e.preventDefault();
8160					$(el+' .month_item').removeClass('selected');
8161					$(this).addClass('selected');
8162					$(el+' .date._selectedCalendar').data('tempYear', $(this).data('year'));
8163					$(el+' .date._selectedCalendar').data('tempMonth', $(this).data('month'));
8164				});
8165			}
8166			bindMonthClick();
8167
8168			// 취소
8169			$(el+' .btn_cancel, '+el+' .mobile_close').on('click', function(){
8170				$(el+' .mobile_back').remove();
8171				$(el+' .date_list_area._yearMonthList').remove();
8172			});
8173
8174			// 확인
8175			$(el+' .btn_confirm').on('click', function(){
8176				let year = $(el+' .date._selectedCalendar').data('tempYear');
8177				let month = $(el+' .date._selectedCalendar').data('tempMonth');
8178				var pid = $(this).closest('.calendar').attr('data-id'),
8179					yearMonth = year + '-' + month;
8180				
8181				if(year && month){
8182					$(el+' .date._selectedCalendar').text(`${year}.${month}`).attr('data-val', `${year}-${month}`);
8183				}
8184				$(el+' .date_list_area._yearMonthList').remove();
8185
8186				$.cl_calendar.init(b.SID, pid, yearMonth);
8187			});
8188		});
8189
8190		// 날짜/시간선택 ampm
8191		$(document).off('click.clockToggle').on('click.clockToggle', '.calendar .calendarModal .timeselector .select:not(.ampm) .selector', function(e){
8192			e.preventDefault();
8193			e.stopPropagation();
8194			const $sel   = $(this).closest('.select');
8195			const $field = $sel.closest('.modal-field');
8196
8197			// ★ 드롭 닫힘을 잠시 무력화하는 락
8198			$field.data('dropOpenLock', true);
8199			setTimeout(()=>{ $field.removeData('dropOpenLock'); }, 150);
8200
8201			$sel.find('.drop').toggle();
8202			$sel.siblings('.select').children('.drop').hide();
8203		});
8204		$(document).on('click.clockCloseOnPick', '.calendar .calendarModal .timeselector .select .drop li', function (e) {
8205			e.stopPropagation();
8206			const $sel = $(this).closest('.select');
8207			setTimeout(() => { $sel.find('.drop').hide(); }, 0);
8208		});
8209		$(document).on('click.clockWidgetArea', '.calendar .bootstrap-datetimepicker-widget', function (e) {
8210			if ($(e.target).closest('.custom-clock .select').length === 0) {
8211				$(this).find('.custom-clock .select .drop').hide();
8212			}
8213		});
8214		$(document).on('click', '.calendar .calendarModal .timeselector .select.ampm .selector', function () {
8215			const $sel   = $(this);
8216			const $field = $sel.closest('.modal-field');
8217			const $input = $field.find('input.daytime');
8218			const dp     = getDp($field, $input);
8219			if (!dp) return;
8220
8221			const m = dp.date() ? dp.date().clone() : moment();
8222			const curType  = ($sel.attr('data-value') || $sel.attr('data-type') || (m.hour() >= 12 ? 'pm' : 'am')).toLowerCase();
8223			const nextType = (curType === 'am') ? 'pm' : 'am';
8224
8225			let H = m.hour();
8226			if (nextType === 'am') { if (H >= 12) H -= 12; } else { if (H < 12) H += 12; }
8227			m.hour(H).second(0);
8228			dp.date(m);
8229
8230			$sel.text(($.lang?.[$field.closest('.calendar').hasClass('en')?'en':'ko']?.['sc.banner.'+nextType]) || nextType.toUpperCase())
8231				.attr({'data-value': nextType, 'data-type': nextType});
8232
8233			$sel.closest('.custom-clock').find('.select .drop').hide();
8234		});
8235		$(document).on('click', '.calendar .calendarModal .timeselector .select.hour .drop li', function () {
8236			const $li    = $(this);
8237			const $field = $li.closest('.modal-field');
8238			const $input = $field.find('input.daytime');
8239			const dp     = getDp($field, $input);
8240			if (!dp) return;
8241
8242			const m = dp.date() ? dp.date().clone() : moment();
8243
8244			const $ampmSel = $li.closest('.timeselector').find('.select.ampm .selector');
8245			const ampm = ($ampmSel.attr('data-value') || $ampmSel.attr('data-type') || (m.hour() >= 12 ? 'pm' : 'am')).toLowerCase();
8246
8247			const hourStr = $li.attr('data-value') || $li.text().trim();
8248			const h12     = parseInt(hourStr, 10) || 12;
8249			const h24     = (ampm === 'pm') ? (h12 % 12) + 12 : (h12 % 12);
8250
8251			m.hour(h24).second(0);
8252			dp.date(m);
8253
8254			const pad = (n)=> (n<10 ? '0'+n : ''+n);
8255			$li.closest('.select.hour').children('.selector').text(pad((h24 % 12) || 12))
8256				.attr('data-type', hourStr);
8257
8258			$li.closest('.custom-clock').find('.select .drop').hide();
8259		});
8260		$(document).on('click', '.calendar .calendarModal .timeselector .select.minute .drop li', function () {
8261			const $li    = $(this);
8262			const $field = $li.closest('.modal-field');
8263			const $input = $field.find('input.daytime');
8264			const dp     = getDp($field, $input);
8265			if (!dp) return;
8266
8267			const minStr = $li.attr('data-value') || $li.text().trim();
8268			let mm = parseInt(minStr, 10); if (isNaN(mm)) mm = 0;
8269
8270			const m = dp.date() ? dp.date().clone() : moment();
8271			m.minute(Math.max(0, Math.min(59, mm))).second(0);
8272			dp.date(m);
8273
8274			const pad = (n)=> (n<10 ? '0'+n : ''+n);
8275			$li.closest('.select.minute').children('.selector').text(pad(mm)).attr('data-type', pad(mm));
8276
8277			// $li.closest('.custom-clock').find('.select .select .drop').hide();
8278			$li.closest('.custom-clock').find('.select .drop').hide();
8279		});
8280
8281
8282		/////// calendar2//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
8283		function calendarOverlayIn(pid) {
8284			$('.userEL'+pid).addClass('modal-open');
8285		}
8286		function calendarOverlayOut(pid) {
8287			$('.userEL'+pid).removeClass('modal-open');
8288		}
8289		function nowTime(){ return new Date(); }
8290		
8291		function readMomentFromField($field){
8292			const $input = $field.find('input.daytime');
8293			const dp = getDp($field, $input);
8294			if (dp && dp.date && dp.date()) return dp.date().clone();
8295			const raw = $input.attr('data-raw') || $input.val();
8296			return raw ? moment(parseToDate(raw)) : null;
8297		}
8298
8299		/** End 필드의 커스텀 clock에서 Start보다 이전 시간들을 disabled 처리 */
8300		function applyEndTimeDisables($endField){
8301			const $overlay = $endField.closest('.calendar-modal-overlay');
8302			const $sField  = $overlay.find('.modal-field.sdate');
8303			const start    = readMomentFromField($sField);
8304			if (!start) return;                           // 시작이 없으면 제한 없음
8305
8306			const $endInput = $endField.find('input.daytime');
8307			const dpEnd     = getDp($endField, $endInput);
8308			const end       = dpEnd && dpEnd.date ? dpEnd.date().clone() : null;
8309
8310			// 1) minDate는 '날짜 단위'로, '변경될 때만' 세팅 (불필요한 리렌더 방지)
8311			if (dpEnd && typeof dpEnd.minDate === 'function') {
8312				const wantMin = start.clone().startOf('day');
8313				let curMin = null;
8314				try { curMin = dpEnd.minDate && dpEnd.minDate(); } catch(e){}
8315				if (!curMin || !moment.isMoment(curMin) || !curMin.isSame(wantMin, 'day')) {
8316				dpEnd.minDate(wantMin);
8317				}
8318			}
8319
8320			const $clock = $endField.find('.custom-clock');
8321			if (!$clock.length) return;
8322
8323			const ampmSel = ($clock.find('.select.ampm .selector').attr('data-type') || ((end && end.hour()>=12) ? 'pm' : 'am')).toLowerCase();
8324			const h12Sel  = parseInt($clock.find('.select.hour .selector').text(), 10) || 12;
8325			const mSel    = parseInt($clock.find('.select.minute .selector').text(), 10) || 0;
8326			const sameDay = end ? end.isSame(start, 'day') : true;
8327			const toH24   = (h12, ap) => (ap==='pm' ? (h12%12)+12 : (h12%12));
8328
8329			// 2) equal-case 강제 리페인트는 '시간/분 드롭이 열려 있을 때만'
8330			//    (= 날짜(day) 셀 클릭 중엔 절대 실행하지 않음)
8331			const timeDropOpen = $endField.find('.custom-clock .select .drop:visible').length > 0;
8332			if (dpEnd && end && start && end.isSame(start) && timeDropOpen) {
8333				$endField.data('suppressDropAutoHide', true);
8334				if (typeof dpEnd.viewDate === 'function') dpEnd.viewDate(end.clone());
8335				dpEnd.date(end.clone().add(1,'ms'));
8336				dpEnd.date(end.clone());
8337				setTimeout(() => { $endField.removeData('suppressDropAutoHide'); }, 80);
8338			}
8339
8340			// 1) AM/PM 드롭 항목
8341			$clock.find('.select.ampm .drop li').each(function(){
8342				const v = ($(this).attr('data-value')||'am').toLowerCase();
8343				const h24 = toH24(h12Sel, v);
8344				const cand = (end ? end.clone() : start.clone()).hour(h24).minute(mSel).second(0);
8345				const dis = sameDay && cand.isBefore(start);
8346				$(this).toggleClass('disabled', dis).attr('aria-disabled', dis ? 'true' : null);
8347			});
8348
8349			// 2) 시간 드롭 항목
8350			$clock.find('.select.hour .drop li').each(function(){
8351				const h12 = parseInt($(this).attr('data-value') || $(this).text(), 10) || 12;
8352				const h24 = toH24(h12, ampmSel);
8353				const cand = (end ? end.clone() : start.clone()).hour(h24).minute(mSel).second(0);
8354				const dis = sameDay && cand.isBefore(start);
8355				$(this).toggleClass('disabled', dis).attr('aria-disabled', dis ? 'true' : null);
8356			});
8357
8358			// 3) 분 드롭 항목
8359			$clock.find('.select.minute .drop li').each(function(){
8360				const mm  = parseInt($(this).attr('data-value') || $(this).text(), 10) || 0;
8361				const h24 = toH24(h12Sel, ampmSel);
8362				const cand = (end ? end.clone() : start.clone()).hour(h24).minute(mm).second(0);
8363				const dis = sameDay && cand.isBefore(start);
8364				$(this).toggleClass('disabled', dis).attr('aria-disabled', dis ? 'true' : null);
8365			});
8366		}
8367
8368		function isAllDayByField($hostField){
8369			const $overlay = $hostField.closest('.calendar-modal-overlay');
8370			return $overlay.find('.all .all-day').is(':checked');
8371		}
8372
8373		function ensureCustomClock($hostField, locale) {
8374			const $overlay = $hostField.closest('.calendar-modal-overlay');
8375			if (!$overlay.length || !$overlay.is(':visible')) return;
8376
8377			const dp = getDp($hostField, $hostField.find('input.daytime'));
8378
8379			let $widget = null;
8380			if (dp) {
8381				try {
8382				const w = (typeof dp.widget === 'function') ? dp.widget() : dp.widget;
8383				if (w) $widget = (w.jquery ? w : $(w));
8384				} catch (e) { /* no-op */ }
8385			}
8386			if (!$widget || !$widget.length) {
8387				$widget = $hostField.find('.bootstrap-datetimepicker-widget:visible').last();
8388				if (!$widget.length) $widget = $('.bootstrap-datetimepicker-widget:visible').last();
8389			}
8390			if (!$widget || !$widget.length || !$widget.is(':visible')) return;
8391
8392			let $list = $widget.find('ul.list-unstyled').first();
8393			let $timeArea = $widget.find('li.timepicker, .timepicker').last();
8394			if (!$list.length && $timeArea.length) $list = $timeArea.closest('ul.list-unstyled');
8395			if (!$list.length) $list = $widget;
8396
8397			// 이미 생성되어 있으면 종료
8398			if ($list.find('.custom-clock-li, .custom-clock').length) return;
8399
8400			const allDay = isAllDayByField($hostField);
8401
8402			// 위젯의 기본 timepicker DOM은 all-day면 숨겨둡니다
8403			if ($timeArea.length) $timeArea.remove();
8404
8405			const cur = (dp && dp.date) ? dp.date() : moment();
8406			const H = cur.hour(), M = cur.minute();
8407			const LANG = locale;
8408			const amLabel  = ($.lang?.[LANG]?.['sc.banner.am']) || 'AM';
8409			const pmLabel  = ($.lang?.[LANG]?.['sc.banner.pm']) || 'PM';
8410			const ampmType = (H >= 12) ? 'pm' : 'am';
8411			const h12 = ((H % 12) || 12);
8412			const pad = (n)=> (n<10 ? '0'+n : ''+n);
8413
8414			// 공통: 취소/저장 버튼 블럭 (시계 유무 상관없이 필요)
8415			const buttonsHtml = `
8416				<tr>
8417				<td class="btnbox">
8418					<div class="calendar-period-btn">
8419					<span class="calendar-period-close">${($.lang?.[LANG]?.['config.cancel']) || 'Cancel'}</span>
8420					</div>
8421					<div class="calendar-period-btn">
8422					<span class="calendar-period-save">${($.lang?.[LANG]?.['config.save']) || 'Save'}</span>
8423					</div>
8424				</td>
8425				</tr>`;
8426
8427			let bodyHtml = '';
8428			if (!allDay) {
8429				// ── 시계 + 버튼 (기존과 동일)
8430				let lisHour = ''; for (let i=1;i<=12;i++) lisHour += `<li data-value="${pad(i)}">${pad(i)}</li>`;
8431				let lisMin  = ''; for (let j=0;j<=59;j++) lisMin  += `<li data-value="${pad(j)}">${pad(j)}</li>`;
8432				bodyHtml = `
8433				<tr class="timeselector">
8434					<td class="btnbox">
8435					<div>
8436						<ul class="select ampm">
8437						<li class="selector" data-type="${ampmType}">${ampmType==='pm'?pmLabel:amLabel}</li>
8438						<ul class="drop"><li data-value="am">${amLabel}</li><li data-value="pm">${pmLabel}</li></ul>
8439						</ul>
8440						<ul class="select hour">
8441						<li class="selector">${pad(h12)}</li>
8442						<ul class="drop">${lisHour}</ul>
8443						</ul>
8444						<ul class="separator"> : </ul>
8445						<ul class="select minute">
8446						<li class="selector">${pad(M)}</li>
8447						<ul class="drop">${lisMin}</ul>
8448						</ul>
8449					</div>
8450					</td>
8451				</tr>
8452				${buttonsHtml}`;
8453			} else {
8454				// ── 버튼만 (달력 + 버튼)
8455				bodyHtml = buttonsHtml;
8456			}
8457
8458			const clockLi = $(`
8459				<li class="custom-clock-li">
8460				<div class="custom-clock ${allDay ? 'clock-compact' : 'clock-full'}">
8461					<table class="table-condensed">
8462					${bodyHtml}
8463					</table>
8464				</div>
8465				</li>`);
8466
8467			const $timeLi = $list.find('li.timepicker, .timepicker').last();
8468			if ($timeLi.length) $timeLi.after(clockLi); else $list.append(clockLi);
8469
8470			const $clock = clockLi.find('.custom-clock');
8471
8472			// 버튼 동작
8473			$clock.off('click.clockBtns')
8474			.on('click.clockBtns', '.calendar-period-save', function () {
8475				const $hostField = $(this).closest('.modal-field');
8476				const $input     = $hostField.find('input.daytime');
8477				const $overlay   = $hostField.closest('.calendar-modal-overlay');
8478				const locale     = $overlay.closest('.calendar').hasClass('en') ? 'en' : 'ko';
8479				const dpStart    = getDp($hostField, $input);
8480				const isAllDay   = isAllDayByField($hostField);
8481
8482				if (dpStart && dpStart.date()) {
8483				$hostField.data('commitFlag', true);
8484
8485				// 저장 시 표시/데이터 형식 분기
8486				let m = dpStart.date().clone();
8487				if (isAllDay) m = m.startOf('day'); // 날짜만 의미
8488
8489				// start 저장 로직 유지 + end 보정
8490				if ($hostField.hasClass('sdate')) {
8491					const $endField = $overlay.find('.modal-field.edate');
8492					const $endInput = $endField.find('input.daytime');
8493					const dpEnd     = getDp($endField, $endInput);
8494
8495					// end 값 읽기
8496					let end = dpEnd && dpEnd.date() ? dpEnd.date().clone() : null;
8497					if (!end) {
8498						const rawEnd = $endInput.attr('data-raw') || $endInput.val();
8499						if (rawEnd) end = moment(parseToDate(rawEnd));
8500					}
8501
8502					// start > end이면 end 자동 보정 (all-day면 같은 날짜, 시간은 의미 없음)
8503					if (!end || m.isAfter(end)) {
8504						// const newEnd = isAllDay ? m.clone() : m.clone().add(1, 'hours');
8505						const newEnd = isAllDay ? m.clone() : m.clone();
8506						if (dpEnd && typeof dpEnd.date === 'function') dpEnd.date(newEnd.clone());
8507
8508						const rawStrEnd   = isAllDay ? newEnd.format('YYYY-MM-DD') : newEnd.format('YYYY-MM-DD HH:mm');
8509						const dispEndHTML = formatDateLocalized(rawStrEnd, locale, 1);
8510						const dispEndTEXT = formatDateLocalized(rawStrEnd, locale);
8511
8512						$endInput.attr('data-raw', rawStrEnd).val(dispEndTEXT).removeClass('empty');
8513
8514						const $endView = $endField.find('.daytime-html');
8515						if ($endView.length) {
8516							$endView.attr('data-raw', rawStrEnd).html(dispEndHTML);
8517						}
8518
8519						$endField.data('commitFlag', true);
8520					}
8521				} else if ($hostField.hasClass('edate')) {
8522					const $startField = $overlay.find('.modal-field.sdate');
8523					const $startInput = $startField.find('input.daytime');
8524					const dpStartInstance = getDp($startField, $startInput);   // sdate
8525					const $endField = $overlay.find('.modal-field.edate');
8526					const $endInput = $endField.find('input.daytime');
8527					const dpEnd = dpStart; // hostField=edate
8528
8529					// 1) 시작(moment) 읽기
8530					let start = dpStartInstance && dpStartInstance.date() ? dpStartInstance.date().clone() : null;
8531					if (!start) {
8532						const rawStart = $startInput.attr('data-raw') || $startInput.val();
8533						if (rawStart) start = moment(parseToDate(rawStart));
8534					}
8535
8536					// 2) end 후보를 "커스텀 시계 선택값"으로 직접 조립
8537					const isAllDay = isAllDayByField($hostField);
8538					const gran = isAllDay ? 'day' : 'minute';
8539					const norm = d => d ? d.clone().seconds(0).milliseconds(0) : null;
8540
8541					let endCandidate;
8542					if (isAllDay) {
8543						// 종일은 날짜만 비교하면 되므로, dp의 날짜(또는 start)로 조립
8544						endCandidate = (dpEnd && dpEnd.date ? dpEnd.date().clone() : (start || moment())).startOf('day');
8545					} else {
8546						// 커스텀 시계에서 AM/PM, 시, 분 읽기
8547						const $clock   = $hostField.find('.custom-clock');
8548						const ap       = ($clock.find('.select.ampm .selector').attr('data-type') || 'am').toLowerCase();
8549						const h12Str   = $clock.find('.select.hour .selector').text().trim() || '12';
8550						const minStr   = $clock.find('.select.minute .selector').text().trim() || '00';
8551						const toH24    = (h12, ap) => ap==='pm' ? (h12%12)+12 : (h12%12);
8552						const h24      = toH24(parseInt(h12Str,10)||12, ap);
8553						const mm       = Math.max(0, Math.min(59, parseInt(minStr,10)||0));
8554
8555						// 같은 "날짜" 위에 시간만 덮어쓰기 (dpEnd가 있으면 그 날짜 사용, 없으면 start 날짜 사용)
8556						const base = (dpEnd && dpEnd.date ? dpEnd.date().clone() : (start || moment()));
8557						endCandidate = base.clone().hours(h24).minutes(mm).seconds(0).milliseconds(0);
8558					}
8559
8560					const startNorm    = norm(start);
8561					const endNorm      = norm(endCandidate);
8562
8563					// 3) 저장 시점 보정: end < start면 end = start
8564					const correctedEnd = (startNorm && endNorm && endNorm.isBefore(startNorm, gran))
8565						? startNorm.clone()
8566						: endNorm.clone();
8567
8568					// 4) 위젯/뷰 갱신은 correctedEnd 기준
8569					if (dpEnd && typeof dpEnd.date === 'function') {
8570						$hostField.data('suppressHide', true);
8571						if (typeof dpEnd.minDate === 'function') dpEnd.minDate(startNorm ? startNorm.clone().startOf('day') : false);
8572						if (typeof dpEnd.viewDate === 'function') dpEnd.viewDate(correctedEnd.clone());
8573						dpEnd.date(correctedEnd.clone()); // (필요시 1ms 흔들기 추가 가능)
8574						setTimeout(() => { $hostField.removeData('suppressHide'); }, 0);
8575					}
8576
8577					// 5) 표기/저장도 correctedEnd만 사용
8578					const rawStrEnd   = isAllDay ? correctedEnd.format('YYYY-MM-DD')
8579												: correctedEnd.format('YYYY-MM-DD HH:mm');
8580					const dispEndHTML = formatDateLocalized(rawStrEnd, locale, 1);
8581					const dispEndTEXT = formatDateLocalized(rawStrEnd, locale);
8582
8583					$endInput.attr('data-raw', rawStrEnd).val(dispEndTEXT).removeClass('empty');
8584					const $endView = $hostField.find('.daytime-html');
8585					if ($endView.length) $endView.attr('data-raw', rawStrEnd).html(dispEndHTML);
8586
8587					try { applyEndTimeDisables($hostField); } catch(e){}
8588					try { if (typeof paintActiveDay === 'function') paintActiveDay($hostField, correctedEnd.clone()); } catch(e){}
8589
8590					$hostField.data('commitFlag', true);
8591				}
8592
8593				// 현재 열려있는 이 피커 닫기
8594				if (dpStart && dpStart.hide) dpStart.hide();
8595				}
8596			})
8597			.on('click.clockBtns', '.calendar-period-close', function () {
8598				const $hostField = $(this).closest('.modal-field');
8599				$hostField.data('commitFlag', false);
8600				const dp = getDp($hostField, $hostField.find('input.daytime'));
8601				dp && dp.hide && dp.hide();
8602			});
8603		}
8604
8605		function closeOtherPickers($overlay, $currentField){
8606			$overlay.find('.modal-field').each(function(){
8607				if (this === $currentField[0]) return;
8608				const dp = $(this).data('DateTimePicker');
8609				if (dp && typeof dp.hide === 'function') dp.hide();
8610			});
8611			$overlay.find('.custom-clock .select .drop').hide();
8612		}
8613
8614		function getDp($field, $input){
8615			return $field.data('DateTimePicker') || $input.data('DateTimePicker');
8616		}
8617
8618		$(document).on('click', '.calendar .modal-field .daytime', function(e) {
8619			e.stopPropagation();
8620			const $input   = $(this);
8621			const $field   = $input.closest('.modal-field');
8622			const $overlay = $input.closest('.calendar-modal-overlay');
8623			const $cal     = $input.closest('.calendar');
8624			const locale   = $cal.hasClass('en') ? 'en' : 'ko';
8625			const lang     = locale;
8626
8627			closeOtherPickers($overlay, $field);
8628
8629			var allDay = $field.siblings('.all').find('.all-day').is(':checked');
8630			const periodOptions = {
8631				format: allDay ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm',
8632				dayViewHeaderFormat: 'YYYY. MM',
8633				minDate: false,
8634				disabledDates: false,
8635				useCurrent: false,
8636				focusOnShow: false,
8637				keepOpen: true,
8638				debug: true,
8639				allowInputToggle: true,
8640				sideBySide: false,
8641				locale: lang,
8642				ignoreReadonly: true,
8643				widgetParent: $field,
8644				widgetPositioning: { horizontal: 'auto', vertical: 'bottom' }
8645			};
8646
8647			let dp = $field.data('DateTimePicker');
8648			if (dp) {
8649				if (typeof dp.show === 'function') dp.show();
8650				else { try { $field.datetimepicker('show'); } catch(e){} }
8651				ensureCustomClock($field, locale);
8652				return;
8653			}
8654
8655			if (typeof $field.datetimepicker !== 'function') {
8656				console.error('bootstrap-datetimepicker가 로드되지 않았습니다.');
8657				return;
8658			}
8659
8660			$field.datetimepicker(periodOptions)
8661				.on('dp.show', function(){
8662					if (!$('.calendar-dp-overlay').length) {
8663						$('<div class="calendar-dp-overlay"></div>').appendTo('.calendar-modal-body');
8664					}
8665
8666					closeOtherPickers($overlay, $field);
8667
8668					const dp   = $field.data('DateTimePicker');
8669					const raw  = $input.attr('data-raw');
8670					const origDisplay = $input.val();
8671					const origRaw     = raw || '';
8672					const base        = raw ? moment(parseToDate(raw)) : (dp && dp.date() ? dp.date().clone() : moment(nowTime()));
8673
8674					$field.data('origDisplay', origDisplay);
8675					$field.data('origRaw',     origRaw);
8676					$field.data('origDate',    base.clone());
8677					$field.data('commitFlag',  false);
8678
8679					if (dp && (!dp.date() || !dp.date().isSame(base))) dp.date(base.clone());
8680
8681					setTimeout(() => {
8682						ensureCustomClock($field, locale);
8683						if ($field.hasClass('edate')) applyEndTimeDisables($field); 
8684					}, 0);
8685				})
8686
8687				.on('dp.change', function(){
8688					const $field = $(this);
8689					const locale = $field.closest('.calendar').hasClass('en') ? 'en' : 'ko';
8690
8691					setTimeout(() => {
8692						ensureCustomClock($field, locale);
8693						if ($field.hasClass('edate')) applyEndTimeDisables($field);
8694
8695						// ★ 프로그램적 변경(equals 리페인트) or 드롭 방금 열림 → 닫기 스킵
8696						if ($field.data('suppressDropAutoHide') || $field.data('dropOpenLock')) return;
8697
8698						// 평소에는 닫기
8699						$field.find('.custom-clock .select .drop').hide();
8700					}, 0);
8701				})
8702
8703				.on('dp.hide', function(){
8704					const $field    = $(this);
8705					const $input    = $field.find('input.daytime');
8706					const $view     = $field.find('.daytime-html'); // 표시용 span
8707					const dp        = $field.data('DateTimePicker');
8708					const committed = !!$field.data('commitFlag');
8709					const origDate  = $field.data('origDate');
8710					const origDisp  = $field.data('origDisplay');
8711					const origRaw   = $field.data('origRaw');
8712
8713					const localeCur = $field.closest('.calendar').hasClass('en') ? 'en' : 'ko';
8714
8715					$('.calendar-dp-overlay').remove();
8716
8717					if (!committed) {
8718						if (dp && origDate) dp.date(origDate.clone());
8719
8720						const isAllDayNow = isAllDayByField($field);
8721						const rollbackIso = origRaw || (origDate ? (isAllDayNow ? origDate.format('YYYY-MM-DD') : origDate.format('YYYY-MM-DD HH:mm')) : null);
8722
8723						if (rollbackIso) {
8724							// ⬇⬇ 여기: HTML/텍스트를 함수의 3번째 인자로 직접 분기
8725							const dispHTML = formatDateLocalized(rollbackIso, localeCur, 1);   // span용(HTML)
8726							const dispTEXT = formatDateLocalized(rollbackIso, localeCur);  // input용(텍스트)
8727
8728							$input.attr('data-raw', rollbackIso).val(dispTEXT).removeClass('empty');
8729							if ($view.length) $view.attr('data-raw', rollbackIso).html(dispHTML);
8730
8731						} else {
8732							if (typeof origDisp !== 'undefined') $input.val(origDisp);
8733							if (typeof origRaw  !== 'undefined') $input.attr('data-raw', origRaw);
8734
8735							if ($view.length) {
8736								if (typeof origRaw !== 'undefined') {
8737									// ⬇⬇ 여기: 표시용은 HTML로
8738									const dispHTML0 = formatDateLocalized(origRaw, localeCur, 1);
8739									$view.attr('data-raw', origRaw).html(dispHTML0);
8740								} else if (typeof origDisp !== 'undefined') {
8741									$view.text(origDisp);
8742								} else {
8743									$view.text('');
8744								}
8745							}
8746						}
8747					} else {
8748						const m = dp && dp.date() ? dp.date().clone() : null;
8749						if (m) {
8750							const isAllDayNow = isAllDayByField($field);
8751							const iso      = isAllDayNow ? m.format('YYYY-MM-DD') : m.format('YYYY-MM-DD HH:mm');
8752							const dispHTML = formatDateLocalized(iso, localeCur, 1);   // span용(HTML)
8753							const dispTEXT = formatDateLocalized(iso, localeCur);  // input용(텍스트)
8754
8755							$input.attr('data-raw', iso).val(dispTEXT).removeClass('empty');
8756							if ($view.length) $view.attr('data-raw', iso).html(dispHTML);
8757						}
8758					}
8759
8760					$field.removeData('origDisplay')
8761							.removeData('origRaw')
8762							.removeData('origDate')
8763							.removeData('commitFlag');
8764
8765					$field.find('.custom-clock .select .drop').hide();
8766			});
8767
8768			const inst = $field.data('DateTimePicker');
8769			if (inst && typeof inst.show === 'function') inst.show();
8770			else { try { $field.datetimepicker('show'); } catch(e){} }
8771		});
8772
8773		$(document).on('click', '.calendar .col-box', function(e) {
8774			var isOpen = $(this).closest('.cfull-box').hasClass('open');
8775			if(isOpen) {
8776				$(this).closest('.cfull-box').removeClass('open');
8777			} else {
8778				$(this).closest('.cfull-box').addClass('open');
8779			}
8780		});
8781
8782		$(document).on('click', '.calendar .scheduleColor', function() {
8783			var colorpick = $(this).attr('data-color');
8784			$(this).closest('.ccol-box').siblings('.col-box').find('.scheduleColorPicker').css('background-color', colorpick).attr('data-color', colorpick);
8785			$(this).closest('.cfull-box').removeClass('open');
8786		});
8787
8788		$(document).on('click', function(e) {
8789			if (!$(e.target).closest('.col-box').length) {
8790				$('.cfull-box').removeClass('open');
8791			}
8792		});
8793
8794		// 닫기 버튼
8795		$(document).on('click', '.calendar .modal-close', function(){
8796			var pid = $(this).closest('.calendar').attr('data-id');
8797			$(this).closest(".calendar-modal-overlay").fadeOut(200, function(){
8798				$(this).remove();
8799			});
8800			calendarOverlayOut(pid);
8801		});
8802
8803		$(document).on('click', '.calendar .all-day', function(e) {
8804			e.stopPropagation();
8805			var checked = ($(this).is(':checked')) ? true : false,
8806				$overlay = $(this).closest('.calendar-modal-overlay'),
8807				locale = ($(this).closest('.calendar').hasClass('en')) ? 'en' : 'ko',
8808				sdate1 = $overlay.find('.sdate .start').val(),
8809				sdate2 = $overlay.find('.sdate .start').attr('data-raw'),
8810				edate1 = $overlay.find('.edate .end').val(),
8811				edate2 = $overlay.find('.edate .end').attr('data-raw'),
8812				sdate1_only = sdate1 ? (sdate1.split(' ')[0] + ' ' + sdate1.split(' ')[1]) : '',
8813				sdate2_only = sdate2 ? sdate2.split(' ')[0] : '',
8814				edate1_only = edate1 ? (edate1.split(' ')[0] + ' ' + edate1.split(' ')[1]) : '',
8815				edate2_only = edate2 ? edate2.split(' ')[0] : '',
8816				time_lang_start = (locale == 'en') ? ' 12:00 PM' : ' 오후 12:00';
8817				time_lang_end = (locale == 'en') ? ' 1:00 PM' : ' 오후 1:00';
8818
8819			// 1) 표시 문자열/원시값 동기화 (기존 로직 유지)
8820			if(checked) {
8821				$overlay.find('.sdate .start').val(sdate1_only);
8822				$overlay.find('.sdate .start').attr('data-raw', sdate2_only);
8823				$overlay.find('.edate .end').val(edate1_only);
8824				$overlay.find('.edate .end').attr('data-raw', edate2_only);
8825				$overlay.find('.stimepicker .tt').remove();
8826        		$overlay.find('.etimepicker .tt').remove();
8827			} else {
8828				$overlay.find('.sdate .start').val(sdate1_only + time_lang_start);
8829				$overlay.find('.sdate .start').attr('data-raw', sdate2_only + ' 12:00');
8830				$overlay.find('.edate .end').val(edate1_only + time_lang_end);
8831				$overlay.find('.edate .end').attr('data-raw', edate2_only + ' 13:00');
8832				$overlay.find('.stimepicker').append('<span class="tt">' + time_lang_start + '</span>');
8833				$overlay.find('.etimepicker').append('<span class="tt">' + time_lang_end + '</span>');
8834			}
8835
8836			$overlay.find('.modal-field.sdate, .modal-field.edate').each(function(){
8837				const $field = $(this);
8838				const $input = $field.find('input.daytime');
8839				const dp     = getDp($field, $input);
8840
8841				if (!dp) return;
8842
8843				// 위젯 얻기
8844				let $widget = null;
8845				try {
8846				const w = (typeof dp.widget === 'function') ? dp.widget() : dp.widget;
8847				if (w) $widget = (w.jquery ? w : $(w));
8848				} catch (err) {}
8849
8850				// 현재 위젯이 화면에 떠 있을 때만 ensureCustomClock으로 시간영역 표시/숨김 반영
8851				if ($widget && $widget.length && $widget.is(':visible')) {
8852					ensureCustomClock($field, locale);
8853				}
8854			});
8855		});
8856
8857		$(document).on('click', '.calendar .schedule_list .del, .calendar .modal-delete', function() {
8858			var mode = $(this).hasClass('modal-delete'),
8859        		locale = ($(this).closest('.calendar').hasClass('en')) ? 'en' : 'ko';
8860				
8861			if (confirm($.lang[locale]['config.calendar.delete'])) {
8862				if(mode) {
8863					var sid = b.SID,
8864						pid = $(this).closest('.calendar').attr('data-id'),
8865						seq = $(this).closest('.calendar-modal-container').find('.calendar-modal-body').find('.seq').val(),
8866						yearMonth = $(this).closest('.calendar-modal-overlay').find('.calendar-modal-container.view .calendar-modal-body .sdate .start').attr('data-raw').substring(0, 7);
8867				} else {
8868					var sid = $(this).siblings('.sid').val(),
8869						seq = $(this).siblings('.seq').val(),
8870						pid = $(this).siblings('.pid').val(),
8871						yearMonth = $('.schedule_list .sdate').val().substring(0, 7);
8872				}
8873				var data_type = ($('.userEL'+pid).attr('data-modoo-type')) ? $('.userEL'+pid).attr('data-modoo-type') : '';
8874
8875				$.ajax({
8876					url: '/template/delete_calendar',
8877					data: { sid: sid, pid: pid, seq: seq, yearMonth: yearMonth },
8878					type: 'POST',
8879					dataType: 'json',
8880					success: function(data) {
8881						checkError(data);
8882						const instance = $.cl_calendar.instances[pid];
8883						// instance.events = data || [];
8884						if (mode) {
8885							$(".calendar-modal-overlay").fadeOut(300);
8886						} else {
8887							$('.modal-overlay-modify').fadeOut(300);
8888						}
8889
8890						if (data_type !== '') {
8891							$.cl_calendar.init(b.SID, pid, yearMonth);
8892						} else {
8893							// ✅ 핵심: 수정 영향권(전/당/다음달)만 캐시 무효화
8894							invalidateAround(pid, yearMonth);
8895
8896							//서버가 돌려준 최신 data(3개월치)를 즉시 캐시에 병합
8897							upsertMonthCacheFromServer(pid, data);
8898
8899							// ✅ 동적 events 소스를 유지한 채로 최신 데이터 다시 요청
8900							if (instance && instance.calendar) {
8901								const v = instance.calendar.view;
8902								const needKeys = monthsInRange(v.currentStart, v.currentEnd);
8903								const pidMap = monthCache.get(pid) || new Map();
8904								const missing = needKeys.filter(k => !pidMap.has(k));
8905								const dt = ($('.userEL'+pid).attr('data-modoo-type')) || '';
8906								const after = () => instance.calendar.refetchEvents();
8907
8908								if (missing.length) {
8909									Promise.all(missing.map(k =>
8909 fetchMonth(pid, k, dt))).finally(after);
8910								} else {
8911									after();
8912								}
8913							} else {
8914								initCalendar(pid);
8915							}
8916						}
8917						calendarOverlayOut(pid);
8918					}
8919				});
8920			}
8921		});
8922
8923		$(document).on('click', '.calendar .go-modify', function() {
8924			var pid = $(this).closest('.calendar-modal-container').find('.pid').val();
8925			if(currentEvent) showCalendarModalEdit(pid, 1, currentDate, currentEvent);
8926			else console.log('선택된 이벤트 없음');
8927		});
8928
8929		// 저장 버튼
8930		let isSaving = false;
8931		$(document).on('click', '.calendar .modal-save, .calendar .modal-modify', function(e) {
8932			e.preventDefault();
8933			e.stopImmediatePropagation();
8934
8935			if (isSaving) return false;
8936
8937			const locale = ($(this).closest('.calendar').hasClass('en')) ? 'en' : 'ko';
8938			const $btn = $(this);
8939			const $overlay = $btn.closest('.calendar-modal-overlay');
8940
8941			if ($overlay.data('saving') === true) return false;
8942
8943			$overlay.data('saving', true);
8944			const $buttons = $overlay.find('.modal-save, .modal-modify').prop('disabled', true).addClass('is-disabled');
8945
8946			var mode = $btn.hasClass('modal-modify'),
8947				pid = $btn.closest('.calendar').attr('data-id'),
8948				data_type = ($('.userEL'+pid).attr('data-modoo-type')) ? $('.userEL'+pid).attr('data-modoo-type') : '';
8949
8950			var title = $btn.closest('.calendar-modal-container').find('.modal-title .ctitle').val(),
8951                color = $btn.closest('.calendar-modal-container').find('.scheduleColorPicker').attr('data-color'),
8952				seq = $btn.parent().siblings('.calendar-modal-body').find('.seq').val(),
8953				sdate = $btn.parent().siblings('.calendar-modal-body').find('.sdate .start').attr('data-raw'),
8954        		edate = $btn.parent().siblings('.calendar-modal-body').find('.edate .end').attr('data-raw'),
8955				fulltime = ($btn.parent().siblings('.calendar-modal-body').find('.all .all-day').prop('checked')) ? 'Y' : 'N',
8956				content = $btn.parent().siblings('.calendar-modal-body').find('.content textarea').val(),
8957				pass = $btn.parent().siblings('.calendar-modal-body').find('.pass').val();
8958
8959			if (!title) {
8960				alert($.lang[locale]['config.calendar.enter-title']);
8961				$overlay.data('saving', false);
8962        		$buttons.prop('disabled', false).removeClass('is-disabled');
8963				return false;
8964			}
8965			if (pass == 'N') {
8966				alert($.lang[locale]['config.calendar.enter-date']);
8967				$overlay.data('saving', false);
8968        		$buttons.prop('disabled', false).removeClass('is-disabled');
8969				return false;
8970			}
8971
8972			var timeRegex = /\s\d{1,2}:\d{2}$/; 
8973			if (fulltime === 'N' && (!timeRegex.test(sdate) || !timeRegex.test(edate))) {
8974				alert($.lang[locale]['config.calendar.enter-time']);
8975				$overlay.data('saving', false);
8976        		$buttons.prop('disabled', false).removeClass('is-disabled');
8977				return false;
8978			}
8979
8980			isSaving = true;
8981			$buttons.prop('disabled', true).addClass('is-disabled');
8982
8983			$(".calendar-modal-overlay").fadeOut(200, function() { $(this).remove(); });
8984			calendarOverlayOut(pid);
8985
8986			const eventData = {
8987				sid: b.SID,
8988				seq: seq,
8989				pid: pid,
8990				month: sdate.substring(0, 7),
8991				sdate: sdate,
8992				stime: (sdate.split(' ')[1]) ? sdate.split(' ')[1] : '00:00',
8993				edate: edate,
8994				etime: (edate.split(' ')[1]) ? edate.split(' ')[1] : '00:00',
8995				fulltime: fulltime,
8996				memo: content,
8997				title: title,
8998				color: color,
8999				check: 2
9000			};
9001
9002			$.ajax({
9003				url: '/template/calendar',
9004				data: { data: eventData, mode: mode, yearMonth: eventData['month'], data_type : data_type },
9005				type: 'POST',
9006				dataType: 'json',
9007				success: function(data) {
9008					checkError(data);
9009					const instance = $.cl_calendar.instances[pid];
9010					instance.events = data || [];
9011
9012					if (data_type != '') {
9013						$.cl_calendar.init(b.SID, pid, sdate.substring(0, 7));
9014					} else {
9015						// ✅ 핵심: 수정 영향권(전/당/다음달)만 캐시 무효화
9016						invalidateAround(pid, sdate.substring(0, 7));
9017
9018						// 서버가 돌려준 최신 data(3개월치)를 즉시 캐시에 병합
9019						upsertMonthCacheFromServer(pid, data);
9020
9021						// ✅ 동적 events 소스를 유지한 채로 최신 데이터 다시 요청
9022						if (instance && instance.calendar) {
9023							const v = instance.calendar.view;
9024							const needKeys = monthsInRange(v.currentStart, v.currentEnd);
9025							const pidMap = monthCache.get(pid) || new Map();
9026							const missing = needKeys.filter(k => !pidMap.has(k));
9027							const dt = ($('.userEL'+pid).attr('data-modoo-type')) || '';
9028							if (missing.length) {
9029								Promise.all(missing.map(k =>
9029 fetchMonth(pid, k, dt)))
9030								.finally(() => instance.calendar.refetchEvents());
9031							} else {
9032								instance.calendar.refetchEvents();
9033							}
9034						} else {
9035							initCalendar(pid);
9036						}
9037						isSaving = false;
9038						$buttons.prop('disabled', false).removeClass('is-disabled');
9039					}
9040
9041					$(".calendar-modal-overlay").fadeOut(200, function() { $(this).remove(); });
9042					calendarOverlayOut(pid);
9043				},
9044				error: function(xhr, status, error) {
9045					console.error("이벤트 저장 실패:", error);
9046				}
9047			});
9048		});
9049
9050		function openEventModal(dateString) {
9051			selectedDate = dateString;
9052			
9053			// 폼 초기화
9054			$('#eventForm')[0].reset();
9055			$('#eventId').val('');
9056			$('#eventStartDate').val(dateString);
9057			$('#eventEndDate').val(dateString);
9058			
9059			// 종료일은 시작일 이후만 선택 가능하도록 설정
9060			$('#eventEndDate').attr('min', dateString);
9061			
9062			// 모달 표시
9063			$('#eventModal').fadeIn(300);
9064		}
9065
9066		function htmlEscape(str) {
9067			return String(str)
9068				.replace(/&/g, "&amp;")
9069				.replace(/</g, "&lt;")
9070				.replace(/>/g, "&gt;")
9071				.replace(/"/g, "&quot;")
9072				.replace(/'/g, "&#39;");
9073		}
9074
9075		// 모달 열기(값이 있을때)
9076		function openEventList(dateString, eventData, el) {
9077			var dayOfWeek = getDayOfWeek(dateString);
9078
9079			var match = [];
9080			for(var i=0; i < eventData.length; i++) {
9081				if(dateString == eventData[i].s_date) {
9082					match.push(eventData[i]);
9083				}
9084			}
9085			
9086			var html = '',
9087			itemCount = 0;
9088			html += '\
9089				<div class="modal-container">\
9090					<div class="modal-header">\
9091						<div class="modal-title">'+ dateString +'&nbsp;&nbsp;&nbsp;'+ dayOfWeek +'</div>\
9092						<button class="modal-close">&times;</button>\
9093					</div>\
9094					<hr>\
9095					<div class="modal-body">\
9096						<ul class="scd_list">\
9097					';
9098			if(match.length == 1) {
9099				var stime = match[0].s_time.substring(0,5),
9100					etime = match[0].e_time.substring(0,5),
9101					fulltime = (match[0].fulltime == 'N') ? stime +' ~ '+ etime : '';
9102				html += '<li data-index="" data-seq="" data-pid="" class="schedule_list _schedule_list">\
9103							<div class="info">\
9104								<span class="datetime">'+ dateString +'('+ dayOfWeek +') '+ fulltime +'</span>\
9105								<input type="hidden" name="sid" class="sid" value="'+ match[0].sid +'">\
9106								<input type="hidden" name="seq" class="seq" value="'+ match[0].seq +'">\
9107								<input type="hidden" name="pid" class="pid" value="'+ match[0].pid +'">\
9108								<input type="hidden" name="sdate" class="sdate" value="'+ match[0].s_date +'">\
9109								<input type="hidden" name="stime" class="stime" value="'+ match[0].s_time +'">\
9110								<input type="hidden" name="edate" class="edate" value="'+ match[0].e_date +'">\
9111								<input type="hidden" name="etime" class="etime" value="'+ match[0].e_time +'">\
9112								<input type="hidden" name="memo" class="memo" value="'+ htmlEscape(match[0].memo) +'">\
9113								<input type="hidden" name="fulltime" class="fulltime" value="'+ match[0].fulltime +'">\
9114							</div>\
9115							<p class="txt">'+ htmlEscape(match[0].memo) +'</p>\
9116						</li>';
9117				itemCount = 1;
9118			} else if(match.length > 1) {
9119				for(var j=0; j < match.length; j++) {
9120					var stime = match[j].s_time.substring(0,5),
9121						etime = match[j].e_time.substring(0,5),
9122						fulltime = (match[j].fulltime == 'N') ? stime +' ~ '+ etime : '';
9123					html += '<li data-index="" data-seq="" data-pid="" class="schedule_list _schedule_list">\
9124							<div class="info">\
9125								<span class="datetime">'+ dateString +'('+ dayOfWeek +') '+ fulltime +'</span>\
9126								<input type="hidden" name="sid" class="sid" value="'+ match[j].sid +'">\
9127								<input type="hidden" name="seq" class="seq" value="'+ match[j].seq +'">\
9128								<input type="hidden" name="pid" class="pid" value="'+ match[j].pid +'">\
9129								<input type="hidden" name="sdate" class="sdate" value="'+ match[j].s_date +'">\
9130								<input type="hidden" name="stime" class="stime" value="'+ match[j].s_time +'">\
9131								<input type="hidden" name="edate" class="edate" value="'+ match[j].e_date +'">\
9132								<input type="hidden" name="etime" class="etime" value="'+ match[j].e_time +'">\
9133								<input type="hidden" name="memo" class="memo" value="'+ htmlEscape(match[j].memo) +'">\
9134								<input type="hidden" name="fulltime" class="fulltime" value="'+ match[j].fulltime +'">\
9135							</div>\
9136							<p class="txt">'+ htmlEscape(match[j].memo) +'</p>\
9137						</li>';
9138					itemCount++;
9139				}
9140			}
9141			html += '</ul></div>\
9142				</div>\
9143			';
9144			if (itemCount <= 1) {
9145				$(el + ' #eventModalModify').addClass('few-items');
9146			} else if (itemCount <= 3) {
9147				$(el + ' #eventModalModify').addClass('mid-items');
9148			} else {
9149				$(el + ' #eventModalModify').addClass('many-items');
9150			}
9151			$(el+' #eventModalModify').empty();
9152			$(el+' #eventModalModify').html(html);
9153			$(el+' #eventModalModify').fadeIn(300);
9154		}
9155
9156		// 모달 닫기 함수
9157		function closeEventModal() {
9158			$('.modal-schedule').fadeOut(300);
9159			selectedDate = null;
9160			currentEventId = null;
9161		}
9162
9163		function formatDate(date) {
9164			const year = date.getFullYear();
9165			const month = String(date.getMonth() + 1).padStart(2, '0');
9166			const day = String(date.getDate()).padStart(2, '0');
9167			return `${year}-${month}-${day}`;
9168		}
9169
9170		function getDayOfWeek(dateString) {
9171			const days = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'];
9172			const date = new Date(dateString);  // 문자열을 Date 객체로 변환
9173			return days[date.getDay()]; // 0(일) ~ 6(토)에 해당하는 요일 반환
9174		}
9175
9176		function createDayElement(date, dateString, isOtherMonth, pid) {
9177			if (!$.cl_calendar.instances[pid]) {
9178				// console.error(`draw called but instance for pid=${pid} is not initialized yet`);
9179				return;
9180			}
9181			var mode = $('.userEL'+pid).attr('data-type2');
9182			const day = date.getDate();
9183			const dayOfWeek = date.getDay();
9184			const isToday = date.toDateString() === new Date().toDateString(); // 예제에서는 3월 18일이 오늘
9185			let className = 'day_wrap _day_wrap';
9186			if (dayOfWeek === 0) className += ' sunday';
9187			if (dayOfWeek === 6) className += ' saturday';
9188			if (isOtherMonth) className += ' other-month';
9189			if (isToday) className += ' today';
9190			
9191			const today_class = (isToday) ? 'today' : '';
9192			const today_themebg = (isToday && mode != 'mwd') ? 'theme_background' : '';
9193			const today_themebd = (isToday) ? 'theme_border' : '';
9194
9195			const dayElement = $('<div>', { 
9196				class: className,
9197				'data-date': dateString
9198			});
9199			
9200			// 일자 표시
9201			const dayNumber = $('<span>', { 
9202				class: `num _dateNum  ${today_themebg}`, 
9203				text: day 
9204			});
9205
9206			// 오늘 표시
9207			if (isToday) {
9208				if(mode == 'mwd') dayNumber.html(`${day}`);
9209        		else dayNumber.html(`<div class="today-indicator">${day}</div>`);
9210			}
9211			// console.log(today_class);
9212			dayElement.append(dayNumber);
9213			dayElement.find('._dateNum').wrap(`<a class="day_num ${today_class} ${today_themebd}"></a>`);
9214			// dayElement.find('.day_num').append('<span class="theme_border"></span>');
9215
9216			var count = 0;
9217			const events = $.cl_calendar.instances[pid].events;
9218			for (var i = 0; i < events.length; i ++) {
9219				if(dateString == events[i].s_date) {
9220					var time = '',
9221						settings = JSON.parse(events[i].settings || '{}');
9222					if(events[i].fulltime == 'Y') time = '종일일정';
9223					else time = events[i].s_time.substring(0, 5) + '-' + events[i].e_time.substring(0, 5);
9224					if(mode == 'mwd') {
9225						dayElement.find('.day_num').append('<div class="event-item" data-seq="'+ events[i].seq +'" style="background-color:'+ settings.color+';">'+ settings.title +'</div>');
9226					} else {
9227						dayElement.find('.day_num').append('<div class="event">'+ time +'</div>');
9228						dayElement.find('.day_num').append('<div class="event_memo">'+ events[i].memo +'</div>');
9229					}
9230					count++;
9231				}
9232			}
9233			if(mode != 'mwd') {
9234
9235				if(count == 1) {
9236					dayElement.find('.day_num').append('<div class="event_mobile">'+ count +'</div>');
9237				} else if(count > 1) {
9238					dayElement.find('.day_num .event').remove();
9239					dayElement.find('.day_num .event_memo').remove();
9240					dayElement.find('.day_num').append('<div class="event more">일정'+ count +'</div>');
9241					dayElement.find('.day_num').append('<div class="event_mobile">' + count +'</div>');
9242				}
9243			}
9244			
9245			return dayElement;
9246		}
9247
9248		function showCalendarModalView(pid, data, fromList) {
9249			var locale = ($('.userEL'+pid).hasClass('en')) ? 'en' : 'ko';
9250			$(".calendar-modal-overlay").remove();
9251
9252			var isGoogle = !!(data.extendedProps && data.extendedProps.isGoogle);
9253			let fulltime = data.extendedProps.fulltime;
9254			if (isGoogle && (fulltime === undefined || fulltime === '' || fulltime === null)) {
9255				// extendedProps에 없으면 event 객체의 allDay로 다시 보정
9256				fulltime = data.allDay ? 'Y' : 'N';
9257			}
9258
9259			let timeShow = '', startShow = '', endShow = '', rawStart = '', rawEnd = '';
9260			if (data.allDay) {
9261				if (data.extendedProps.fulltime === 'Y') { // 종일 범위
9262					rawStart = data.extendedProps.start_date;          // "YYYY-MM-DD"
9263                    rawEnd   = data.extendedProps.end_date;            // "YYYY-MM-DD"
9264					timeShow  = formatRangeLocalized(rawStart, rawEnd, locale, { allDay: true });
9265					startShow = formatDateLocalized(rawStart, locale);
9266					endShow   = formatDateLocalized(rawEnd,   locale);
9267				} else { // 연속 일정(시간 포함)
9268					rawStart = `${data.extendedProps.start_date} ${data.extendedProps.s_time}`;
9269					rawEnd   = `${data.extendedProps.end_date} ${data.extendedProps.e_time}`;
9270					timeShow  = formatRangeLocalized(rawStart, rawEnd, locale);
9271					startShow = formatDateLocalized(rawStart, locale);
9272					endShow   = formatDateLocalized(rawEnd,   locale);
9273				}
9274			} else { // 하루 일정(시간 지정)
9275				rawStart = `${data.extendedProps.start_date} ${data.extendedProps.s_time}`;
9276				rawEnd   = `${data.extendedProps.end_date} ${data.extendedProps.e_time}`;
9277				timeShow  = formatRangeLocalized(rawStart, rawEnd, locale);
9278				startShow = formatDateLocalized(rawStart, locale);
9279				endShow   = formatDateLocalized(rawEnd,   locale);
9280			}
9281
9282			const displayStartText = formatDateLocalized(rawStart, locale, 1);
9283    		const displayEndText   = formatDateLocalized(rawEnd, locale, 1);
9284
9285			let backButtonHtml = fromList ? `<button class="back-button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M14.35 17.29 7.06 10l7.29-7.29-.7-.71-8 8 .7.71 7.3 7.29.7-.71z"/></svg></button>` : ``; 
9286			let modalHeaderClass = fromList ? '' : 'no-back';
9287			var footerButtonsHtml = '',
9288				textTitle = '';
9289			if (!isGoogle) {
9290				footerButtonsHtml = `
9291					<button class="modal-delete">${$.lang[locale]['config.delete']}</button>
9292					<button class="go-modify">${$.lang[locale]['config.modify']}</button>
9293				`;
9294				textTitle = data._def.title;
9295			} else {
9296				textTitle = (data._def.title == 'undefined') ? (locale == 'ko') ? '(제목 없음)' : '(No title)' : data._def.title;
9297			}
9298
9299			let modalHtml = `
9300				<div class="calendar-modal-overlay" style="display:none;">
9301					<div class="calendar-modal-container view">
9302						<div class="calendar-modal-header">
9303							${backButtonHtml}
9304							<button class="modal-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M17.85 17.15 10.7 10l7.15-7.15c.2-.19.2-.51.01-.71-.19-.2-.51-.2-.71-.01l-.01.01-7.15 7.15-7.14-7.14a.504.504 0 0 0-.71.01c-.19.19-.19.5 0 .69L9.29 10l-7.15 7.15c-.2.19-.2.51-.01.71.19.2.51.2.71.01l.01-.01L10 10.71l7.15 7.15c.19.2.51.2.71.01.2-.19.2-.51.01-.71l-.01-.01Z"/></svg></button>
9305						</div>
9306						<div class="calendar-modal-body">
9307							<input type="hidden" class="pid" value="${pid}">
9308							<input type="hidden" class="seq" value="${data.extendedProps.seq}">
9309							<input type="hidden" id='sale-start-datetime' value="">
9310							<div class="col-box">
9311								<input type="text" class="scheduleColorPicker" data-color="${data.backgroundColor}" style="background-color: ${data.backgroundColor}" readonly>
9312								<span class="modal-title">${textTitle}</span>
9313							</div>
9314							<div class="date-box">
9315								<label><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M14 9.5h-3.5V5c0-.28-.22-.5-.5-.5s-.5.22-.5.5v5c0 .28.22.5.5.5h4c.28 0 .5-.22.5-.5s-.22-.5-.5-.5Z" style="fill:#cool-grey ;"/><path d="M10 2c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8Zm0 15c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7c0 3.86-3.14 7-7 7Z" style="fill:#cool-grey ;"/></svg></label>
9316								<div class="modal-field sdate">
9317									<span class="daytime daytime-html start stimepicker" data-raw="${rawStart}" readonly>${displayStartText}</span>
9318								</div>
9319								<span class="middle"> ~ </span>
9320								<div class="modal-field edate">
9321									<span class="daytime daytime-html end etimepicker" data-raw="${rawEnd}" readonly>${displayEndText}</span>
9322								</div>
9323							</div>
9324							<div class="modal-field content">
9325								<label><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M2 5h16v1H2z"/><path d="M2 9h16v1H2z"/><path d="M2 13h8v1H2z"/><path d="M50 9.5h-3.5V5c0-.28-.22-.5-.5-.5s-.5.22-.5.5v5c0 .28.22.5.5.5h4c.28 0 .5-.22.5-.5s-.22-.5-.5-.5"/><path d="M46 3c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.14-7-7 3.14-7 7-7m0-1c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8Z"/></svg></label>
9326								<span>${nl2br(data.extendedProps.memo) || '&nbsp;'}</span>
9327							</div>
9328						</div>`;
9329				if(property.UMEMBER.check_adm || property.UMEMBER.check_uadm) {
9330					modalHtml += `
9331						<div class="calendar-modal-footer">
9332							${footerButtonsHtml}
9333						</div>`;
9334					}
9335				modalHtml += `
9336					</div>
9337					<div class="calendar-modal-container mobile">
9338						<div class="calendar-modal-header ${modalHeaderClass}">
9339							${fromList ? `<button class="back-button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="m17.35 2.71-.7-.71-9.3 9.29-.7.71 10 10 .7-.71L8.06 12l9.29-9.29z"/></svg></button>` : ``}
9340							<div class="text-right">`;
9341			if(property.UMEMBER.check_adm || property.UMEMBER.check_uadm) {
9342				if(!isGoogle) {
9343					modalHtml += `<button class="mod go-modify"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="m21.27 2.95-.21-.21c-.47-.47-1.1-.73-1.77-.73-.66 0-1.3.26-1.77.73L3.25 17 2 22l5-1.25L21.27 6.48c.98-.98.98-2.56 0-3.53ZM6.43 19.75l-2.91.73.73-2.91L15.56 6.26l2.18 2.18-11.3 11.3ZM20.48 5.7l-2.04 2.04-2.18-2.18 2.04-2.04c.26-.26.61-.41.98-.41s.72.15.98.41l.21.21c.54.54.54 1.42 0 1.96Z"/></svg></button>
9344									<button class="del modal-delete"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M16.17 4.5V2H7.83v2.5h-5v1.25H4.5v12.92C4.5 20.51 5.99 22 7.83 22h8.33c1.84 0 3.33-1.49 3.33-3.33V5.75h1.67V4.5h-5ZM9.08 3.25h5.83V4.5H9.08V3.25Zm9.17 15.42c0 1.15-.93 2.08-2.08 2.08H7.83c-1.15 0-2.08-.93-2.08-2.08V5.75h12.5v12.92Z" class="st0"/><path d="M9.08 8.67h1.25v9.17H9.08zM13.67 8.67h1.25v9.17h-1.25z"/></svg></button>
9345								`;
9346				}
9347			}
9348			modalHtml += `<button class="modal-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
9348<path d="M21 3.71 20.29 3 12 11.29 3.71 3 3 3.71 11.29 12 3 20.29l.71.71L12 12.71 20.29 21l.71-.71L12.71 12 21 3.71z"/></svg></button>
9349							</div>
9350						</div>
9351						<div class="calendar-modal-body">
9352							<input type="hidden" class="pid" value="${pid}">
9353							<input type="hidden" class="seq" value="${data.extendedProps.seq}">
9354							<div class="title">
9355								<div class="title-left ${(property.UMEMBER.check_adm || property.UMEMBER.check_uadm) ? '' : 'notadm'}">
9356									<input type="text" class="scheduleColorPicker" data-color="${data.backgroundColor}" style="background-color: ${data.backgroundColor}" readonly>
9357									<span class="modal-title">${textTitle}</span>
9358								</div>
9359							</div>
9360							<div class="modal-field mdate">
9361								<label><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M14 9.5h-3.5V5c0-.28-.22-.5-.5-.5s-.5.22-.5.5v5c0 .28.22.5.5.5h4c.28 0 .5-.22.5-.5s-.22-.5-.5-.5Z" style="fill:#cool-grey ;"/><path d="M10 2c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8Zm0 15c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7c0 3.86-3.14 7-7 7Z" style="fill:#cool-grey ;"/></svg></label>
9362								<div class="date-box">
9363									<div class="modal-field sdate">
9364										<span class="daytime daytime-html start stimepicker" data-raw="${rawStart}" readonly>${displayStartText}</span>
9365									</div>
9366									<span class="middle"> ~ </span>
9367									<div class="modal-field edate">
9368										<span class="daytime daytime-html end etimepicker" data-raw="${rawEnd}" readonly>${displayEndText}</span>
9369									</div>
9370								</div>
9371							</div>
9372							<div class="modal-field mcontent">
9373								<label><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M2 5h16v1H2z"/><path d="M2 9h16v1H2z"/><path d="M2 13h8v1H2z"/><path d="M50 9.5h-3.5V5c0-.28-.22-.5-.5-.5s-.5.22-.5.5v5c0 .28.22.5.5.5h4c.28 0 .5-.22.5-.5s-.22-.5-.5-.5"/><path d="M46 3c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.14-7-7 3.14-7 7-7m0-1c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8Z"/></svg></label>
9374								<span>${nl2br(data.extendedProps.memo) || '&nbsp;'}</span>
9375							</div>
9376						</div>
9377					</div>
9378				</div>`;
9379
9380			const $modalWrapper = $('.userEL' + pid).find(".calendarModal");
9381			$modalWrapper.append(modalHtml);
9382			calendarOverlayIn(pid);
9383			$modalWrapper.find(".calendar-modal-overlay").fadeIn(200);
9384
9385			if (fromList) {
9386				$modalWrapper.off('click', '.back-button').on('click', '.back-button', function () {
9387					$(".calendar-modal-overlay").remove();
9388					if (lastEventsList) {
9389						openMoreEventsModal(pid, lastEventsList, lastEventsWeekday);
9390					}
9391				});
9392			}
9393		}
9394
9395		function parseToDate(str) {
9396			if (!str) return new Date();
9397			if (str.includes('T')) return new Date(str);
9398			const [d, t] = str.trim().split(' ');
9399			const [yy, mm, dd] = d.split('-').map(Number);
9400			if (!t) return new Date(yy, mm - 1, dd, 0, 0);
9401			const [HH, MM] = t.split(':').map(Number);
9402			return new Date(yy, mm - 1, dd, HH, MM);
9403		}
9404
9405		function formatDateLocalized(rawStr, locale, isInput) {
9406			isInput = (isInput == undefined || isInput == '') ? false : true;
9407			const dt = parseToDate(rawStr);
9408			const year = dt.getFullYear();
9409			const month = String(dt.getMonth() + 1).padStart(2, '0');
9410			const day = String(dt.getDate()).padStart(2, '0');
9411			const koDays = ['일','월','화','수','목','금','토'];
9412			const enDays = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
9413			const weekday = (locale === 'en') ? enDays[dt.getDay()] : koDays[dt.getDay()];
9414			const hasTime = String(rawStr).includes(':') || String(rawStr).includes('T');
9415
9416			const dateStr = (locale === 'en') 
9417				? `${month}.${day}.${year}` 
9418				: `${year}.${month}.${day}`;
9419
9420			if (!hasTime) return `${dateStr} (${weekday})`;
9421
9422			let H = dt.getHours();
9423			const mm = String(dt.getMinutes()).padStart(2, '0');
9424			let h12 = H % 12; if (h12 === 0) h12 = 12;
9425
9426			if (locale === 'en') {
9427				const ampm = (H < 12) ? 'AM' : 'PM';
9428				if(isInput) return `${weekday} ${dateStr} <span class='tt'>${h12}:${mm} ${ampm}</span>`;
9429        		else return `${weekday} ${dateStr} ${h12}:${mm} ${ampm}`;
9430			} else {
9431				const ampm = (H < 12) ? '오전' : '오후';
9432				if(isInput) return `${dateStr} (${weekday}) <span class='tt'>${ampm} ${h12}:${mm}</span>`;
9433        		else return `${dateStr} (${weekday}) ${ampm} ${h12}:${mm}`;
9434			}
9435		}
9436
9437		function formatTimeOnly(rawStr, locale) {
9438			const dt = parseToDate(rawStr);
9439			let H = dt.getHours();
9440			const mm = String(dt.getMinutes()).padStart(2, '0');
9441			let h12 = H % 12; if (h12 === 0) h12 = 12;
9442
9443			if (locale === 'en') {
9444				const ampm = (H < 12) ? 'AM' : 'PM';
9445				return `${h12}:${mm} ${ampm}`;
9446			} else {
9447				const ampm = (H < 12) ? '오전' : '오후';
9448				return `${ampm} ${h12}:${mm}`;
9449			}
9450		}
9451
9452		// 범위 포맷: 같은 날이면 "왼쪽=전체, 오른쪽=시간만", 다른 날이면 양쪽 모두 전체
9453		function formatRangeLocalized(startRaw, endRaw, locale, {allDay=false} = {}) {
9454			const s = parseToDate(startRaw);
9455			const e = parseToDate(endRaw);
9456
9457			const sameDay = (s.getFullYear() === e.getFullYear() &&
9458							s.getMonth() === e.getMonth() &&
9459							s.getDate() === e.getDate());
9460
9461			if (allDay) {
9462				// 종일 범위: 날짜만
9463				const left  = formatDateLocalized(startRaw.split(' ')[0], locale);
9464				const right = formatDateLocalized(endRaw.split(' ')[0], locale);
9465				return `${left} ~ ${right}`;
9466			}
9467
9468			if (sameDay) {
9469				const left  = formatDateLocalized(startRaw, locale);
9470				const right = formatTimeOnly(endRaw, locale);
9471				return `${left} ~ ${right}`;
9472			} else {
9473				const left  = formatDateLocalized(startRaw, locale);
9474				const right = formatDateLocalized(endRaw,   locale);
9475				return `${left} ~ ${right}`;
9476			}
9477		}
9478
9479		function swallowNextTapOnce(ttl = 400){
9480			const stop = (e) => {
9481				e.preventDefault();
9482				e.stopPropagation();
9483				e.stopImmediatePropagation && e.stopImmediatePropagation();
9484				cleanup();
9485			};
9486			const cleanup = () => {
9487				document.removeEventListener('click', stop, true);
9488				document.removeEventListener('pointerup', stop, true);
9489				document.removeEventListener('touchend', stop, true);
9490			};
9491			document.addEventListener('click', stop, true);
9492			document.addEventListener('pointerup', stop, true);
9493			document.addEventListener('touchend', stop, true);
9494			setTimeout(cleanup, ttl);
9495		}
9496
9497		function showCalendarModalEdit(pid, mode, date, data) {
9498			// console.log('edit');
9499			swallowNextTapOnce();
9500			var locale = ($('.userEL'+pid).hasClass('en')) ? 'en' : 'ko';
9501			var data = (typeof data != 'undefined') ? data : '';
9502
9503			$(".calendar-modal-overlay").remove();
9504
9505			if(mode == 0) {
9506				// console.log(date);
9507				var startDate = '',
9508					endDate = '',
9509					checked = '';
9510				startDate = date[0];
9511				endDate = date[1];
9512				checked = (date[2] == 1) ? 'checked' : '';
9513
9514				const displayStart = formatDateLocalized(startDate, locale);
9515        		const displayEnd   = formatDateLocalized(endDate, locale);
9516				const displayStartText = formatDateLocalized(startDate, locale, 1);
9517        		const displayEndText   = formatDateLocalized(endDate, locale, 1);
9518        
9519				var modalHtml = `
9520					<div class="calendar-modal-overlay" style="display:none;">
9521						<div class="calendar-modal-container">
9522							<div class="calendar-modal-header">
9523								<div class="cfull-box">
9524									<div class="col-box"><input type="text" class="scheduleColorPicker" data-color="#fcbf54" style="background-color: #fcbf54;" readonly></div>
9525									<div class="ccol-box">
9526										<input type="text" data-color="#ff6f61" class="scheduleColor sc1" readonly>
9527										<input type="text" data-color="#f63824" class="scheduleColor sc2" readonly>
9528										<input type="text" data-color="#ee6c3b" class="scheduleColor sc3" readonly>
9529										<input type="text" data-color="#fcbf54" class="scheduleColor sc4" readonly>
9530										<input type="text" data-color="#14c285" class="scheduleColor sc5" readonly>
9531										<input type="text" data-color="#1d9f54" class="scheduleColor sc6" readonly><br>
9532										<input type="text" data-color="#3498db" class="scheduleColor sc7" readonly>
9533										<input type="text" data-color="#022b79" class="scheduleColor sc8" readonly>
9534										<input type="text" data-color="#9b59b6" class="scheduleColor sc9" readonly>
9535										<input type="text" data-color="#e91e63" class="scheduleColor sc10" readonly>
9536										<input type="text" data-color="#566573" class="scheduleColor sc11" readonly>
9537										<input type="text" data-color="#95a5a6" class="scheduleColor sc12" readonly>
9538									</div>
9539								</div>
9540								<span class="modal-title"><input type="text" class="ctitle" value="" placeholder="${$.lang[locale]['config.calendar.title.placeholder']}" maxlength="200"></span>
9541								<button class="modal-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M21 3.71 20.29 3 12 11.29 3.71 3 3 3.71 11.29 12 3 20.29l.71.71L12 12.71 20.29 21l.71-.71L12.71 12 21 3.71z"/></svg></button>
9542							</div>
9543							<div class="calendar-modal-body">
9544								<input type="hidden" class="pass" value="Y">
9545								<input type="hidden" id='sale-start-datetime' value="">
9546								<div class="modal-field all">
9547									<label><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M14 9.5h-3.5V5c0-.28-.22-.5-.5-.5s-.5.22-.5.5v5c0 .28.22.5.5.5h4c.28 0 .5-.22.5-.5s-.22-.5-.5-.5Z" style="fill:#cool-grey ;"/><path d="M10 2c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8Zm0 15c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7c0 3.86-3.14 7-7 7Z" style="fill:#cool-grey ;"/></svg></label>
9548									<label for="all-day">${$.lang[locale]['config.calendar.fulltime']}</label>
9549									<span class="bc-tp-btn switch-wrap">
9550										<label class="switch prop-wrap">
9551											<input type="checkbox" class="switch-input all-day" id="all-day" data-el="${selectEL}" ${checked}>
9552											<span class="switch-label" data-on="On" data-off="Off"></span>
9553											<span class="switch-handle"></span>
9554										</label>
9555									</span>
9556								</div>
9557								<div class="date-box">
9558									<div class="modal-field sdate">
9559										<label>&nbsp;</label>
9560										<input class="daytime start" type="text" placeholder="${$.lang[locale]['config.calendar.datetime']}" value="${displayStart}" data-raw="${startDate}" readonly>
9561										<span class="daytime daytime-html start stimepicker" type="text" placeholder="${$.lang[locale]['config.calendar.datetime']}" data-raw="${startDate}" readonly>${displayStartText}</span>
9562									</div>
9563									<span class="middle"> ~ </span>
9564									<div class="modal-field edate">
9565										<input class="daytime end" type="text" placeholder="${$.lang[locale]['config.calendar.datetime']}" value="${displayEnd}" data-raw="${endDate}" readonly>
9566										<span class="daytime daytime-html end etimepicker" type="text" placeholder="${$.lang[locale]['config.calendar.datetime']}" data-raw="${endDate}" readonly>${displayEndText}</span>
9567									</div>
9568								</div>
9569								<div class="modal-field content">
9570									<label><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M2 5h16v1H2z"/><path d="M2 9h16v1H2z"/><path d="M2 13h8v1H2z"/><path d="M50 9.5h-3.5V5c0-.28-.22-.5-.5-.5s-.5.22-.5.5v5c0 .28.22.5.5.5h4c.28 0 .5-.22.5-.5s-.22-.5-.5-.5"/><path d="M46 3c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.14-7-7 3.14-7 7-7m0-1c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8Z"/></svg></label>
9571									<textarea placeholder="${$.lang[locale]['config.calendar.content.placeholder']}"></textarea>
9572								</div>
9573							</div>
9574							<div class="calendar-modal-footer">
9575								<button class="modal-save">${$.lang[locale]['config.save']}</button>
9576							</div>
9577						</div>
9578					</div>`;
9579
9580			} else {
9581				var startDate, endDate;
9582				if(data.extendedProps.fulltime == 'Y') {
9583					startDate = data.extendedProps.start_date;
9584					endDate = data.extendedProps.end_date;
9585				} else {
9586					startDate = data.extendedProps.start_date + ' ' + data.extendedProps.s_time,
9587            		endDate = data.extendedProps.end_date + ' ' + data.extendedProps.e_time;
9588				}
9589
9590				const displayStart = formatDateLocalized(startDate, locale);
9591        		const displayEnd   = formatDateLocalized(endDate, locale);
9592				const displayStartText = formatDateLocalized(startDate, locale, 1);
9593        		const displayEndText   = formatDateLocalized(endDate, locale, 1);
9594
9595				var modalHtml = `
9596					<div class="calendar-modal-overlay" style="display:none;">
9597						<div class="calendar-modal-container">
9598							<div class="calendar-modal-header">
9599								<button class="back-button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
9599<path d="m17.35 2.71-.7-.71-9.3 9.29-.7.71 10 10 .7-.71L8.06 12l9.29-9.29z"/></svg></button>
9600								<button class="modal-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M21 3.71 20.29 3 12 11.29 3.71 3 3 3.71 11.29 12 3 20.29l.71.71L12 12.71 20.29 21l.71-.71L12.71 12 21 3.71z"/></svg></button>
9601							</div>
9602							<div class="calendar-modal-body">
9603								<input type="hidden" class="pass" value="Y">
9604								<input type="hidden" class="seq" value="${data.extendedProps.seq}">
9605								<input type="hidden" id='sale-start-datetime' value="">
9606								<div class="title-modify">
9607									<div class="cfull-box">
9608										<div class="col-box"><input type="text" class="scheduleColorPicker" data-color="${data.backgroundColor}" style="background-color:${data.backgroundColor};" readonly></div>
9609										<div class="ccol-box">
9610											<input type="text" data-color="#ff6f61" class="scheduleColor sc1" readonly>
9611											<input type="text" data-color="#f63824" class="scheduleColor sc2" readonly>
9612											<input type="text" data-color="#ee6c3b" class="scheduleColor sc3" readonly>
9613											<input type="text" data-color="#fcbf54" class="scheduleColor sc4" readonly>
9614											<input type="text" data-color="#14c285" class="scheduleColor sc5" readonly>
9615											<input type="text" data-color="#1d9f54" class="scheduleColor sc6" readonly><br>
9616											<input type="text" data-color="#3498db" class="scheduleColor sc7" readonly>
9617											<input type="text" data-color="#022b79" class="scheduleColor sc8" readonly>
9618											<input type="text" data-color="#9b59b6" class="scheduleColor sc9" readonly>
9619											<input type="text" data-color="#e91e63" class="scheduleColor sc10" readonly>
9620											<input type="text" data-color="#566573" class="scheduleColor sc11" readonly>
9621											<input type="text" data-color="#95a5a6" class="scheduleColor sc12" readonly>
9622										</div>
9623									</div>
9624									<span class="modal-title"><input type="text" class="ctitle" value="${data._def.title}" placeholder="${$.lang[locale]['config.calendar.title.placeholder']}" maxlength="200"></span>
9625								</div>
9626								<div class="modal-field all">
9627									<label><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M14 9.5h-3.5V5c0-.28-.22-.5-.5-.5s-.5.22-.5.5v5c0 .28.22.5.5.5h4c.28 0 .5-.22.5-.5s-.22-.5-.5-.5Z" style="fill:#cool-grey ;"/><path d="M10 2c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8Zm0 15c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7c0 3.86-3.14 7-7 7Z" style="fill:#cool-grey ;"/></svg></label>
9628									<label for="all-day">${$.lang[locale]['config.calendar.fulltime']}</label>
9629									<span class="bc-tp-btn switch-wrap">
9630										<label class="switch prop-wrap">
9631											<input type="checkbox" class="switch-input all-day" id="all-day" data-el="${selectEL}" ${(data.extendedProps.fulltime == 'Y') ? 'checked' : ''}>
9632											<span class="switch-label" data-on="On" data-off="Off"></span>
9633											<span class="switch-handle"></span>
9634										</label>
9635									</span>
9636								</div>
9637								<div class="date-box">
9638									<div class="modal-field sdate">
9639										<label>&nbsp;</label>
9640										<input class="daytime start" type="text" placeholder="${$.lang[locale]['config.calendar.datetime']}" value="${displayStart}" data-raw="${startDate}" readonly>
9641										<span class="daytime daytime-html start stimepicker" placeholder="${$.lang[locale]['config.calendar.datetime']}" data-raw="${startDate}" readonly>${displayStartText}</span>
9642									</div>
9643									<span class="middle"> ~ </span>
9644									<div class="modal-field edate">
9645										<input class="daytime end" type="text" placeholder="${$.lang[locale]['config.calendar.datetime']}" value="${displayEnd}" data-raw="${endDate}" readonly>
9646										<span class="daytime daytime-html end etimepicker" type="text" placeholder="${$.lang[locale]['config.calendar.datetime']}" data-raw="${endDate}" readonly>${displayEndText}</span>
9647									</div>
9648								</div>
9649								<div class="modal-field content">
9650									<label><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M2 5h16v1H2z"/><path d="M2 9h16v1H2z"/><path d="M2 13h8v1H2z"/><path d="M50 9.5h-3.5V5c0-.28-.22-.5-.5-.5s-.5.22-.5.5v5c0 .28.22.5.5.5h4c.28 0 .5-.22.5-.5s-.22-.5-.5-.5"/><path d="M46 3c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.14-7-7 3.14-7 7-7m0-1c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8Z"/></svg></label>
9651                            		<textarea placeholder="${$.lang[locale]['config.calendar.content.placeholder']}">${data.extendedProps.memo}</textarea>
9652								</div>
9653							</div>
9654							<div class="calendar-modal-footer">
9655								<button class="modal-modify">${$.lang[locale]['config.save']}</button>
9656							</div>
9657						</div>
9658					</div>`;
9659			}
9660
9661			$('.userEL'+pid).find(".calendarModal").append(modalHtml);
9662			calendarOverlayIn(pid);
9663			$('.userEL'+pid).find(".calendar-modal-overlay").fadeIn(200);
9664			$('.userEL'+pid).find('.ctitle').focus();
9665			refitAll();
9666		}
9667
9668		function formatTime(time, locale) {
9669			let [hour, minute] = time.split(':').map(Number);
9670
9671			let period = hour < 12 ? $.lang[locale]['config.calendar.am'] : $.lang[locale]['config.calendar.pm'];
9672			let hour12 = hour % 12 || 12;
9673			let minuteText = minute.toString().padStart(2, '0');
9674
9675			return `${period} ${hour12}:${minuteText}`;
9676		}
9677
9678		function toDateStr(d) {
9679			if (!d) return '';
9680			const y = d.getFullYear();
9681			const m = String(d.getMonth() + 1).padStart(2, '0');
9682			const day = String(d.getDate()).padStart(2, '0');
9683			return `${y}-${m}-${day}`;
9684		}
9685
9686		function fmtHMFromDate(d, locale) {
9687			if (!d) return '';
9688			const hour = d.getHours();
9689			const minute = String(d.getMinutes()).padStart(2,'0');
9690			if (locale === 'ko') {
9691				const period = hour < 12 ? $.lang[locale]['config.calendar.am'] : $.lang[locale]['config.calendar.pm'];
9692				const hour12 = hour % 12 || 12;
9693				return `${period} ${hour12}:${minute}`;
9694			}
9695			return new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit' }).format(d);
9696		}
9697
9698		function openMoreEventsModal(pid, events, weekday) {
9699			var locale = ($('.userEL'+pid).hasClass('en')) ? 'en' : 'ko';
9700			if (!Array.isArray(events)) {
9701				events = [events];
9702			}
9703
9704			lastEventsList = events;
9705			lastEventsWeekday = weekday;
9706			const dayNum = weekday[0].getDate();
9707
9708			const filteredEvents = events.filter(ev => !(ev.classNames && ev.classNames.includes('holiday-event')));
9709
9710			const sorted = filteredEvents.slice().sort((a, b) => {
9711				const isMulti = (ev) => {
9712					const sd = ev.extendedProps?.start_date;
9713					const ed = ev.extendedProps?.end_date;
9714					if (sd && ed && sd !== ed) return true; 
9715					if (ev.allDay && ev.start && ev.end) return (ev.end - ev.start) >= 86400000;
9716					return false;
9717				};
9718
9719				const am = isMulti(a), bm = isMulti(b);
9720				if (am !== bm) return am ? -1 : 1;   
9721
9722				const as = a.start ? a.start.getTime() : 0;
9723				const bs = b.start ? b.start.getTime() : 0;
9724				if (as !== bs) return as - bs;
9725
9726				const ae = a.end ? a.end.getTime() : Number.POSITIVE_INFINITY;
9727				const be = b.end ? b.end.getTime() : Number.POSITIVE_INFINITY;
9728				if (ae !== be) return ae - be;
9729
9730				return (a.title || '').localeCompare(b.title || '');
9731			});
9732
9733			const googleColorRaw = (googleColor && googleColor.get(pid)) || '';
9734    		const googleColorHex = googleColorRaw ? (googleColorRaw.startsWith('#') ? googleColorRaw : ('#' + googleColorRaw)) : ''; 
9735
9736			$(".calendar-modal-overlay").remove();
9737			let modalHtml = `
9738				<div class="calendar-modal-overlay" style="display:none;">
9739					<div class="calendar-modal-container">
9740						<div class="calendar-modal-header">
9741							<h4>${dayNum} <span>${weekday[1]}</span></h4>
9742							<button class="modal-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M17.85 17.15 10.7 10l7.15-7.15c.2-.19.2-.51.01-.71-.19-.2-.51-.2-.71-.01l-.01.01-7.15 7.15-7.14-7.14a.504.504 0 0 0-.71.01c-.19.19-.19.5 0 .69L9.29 10l-7.15 7.15c-.2.19-.2.51-.01.71.19.2.51.2.71.01l.01-.01L10 10.71l7.15 7.15c.19.2.51.2.71.01.2-.19.2-.51.01-.71l-.01-.01Z"/></svg></button>
9743						</div>
9744						<div class="calendar-modal-body">
9745							<input type="hidden" id='sale-start-datetime' value="">
9746							<div class="schedule-list">
9747								<ul>
9748			`;
9749
9750			for (let i = 0; i < sorted.length; i++) {
9751				var ev = sorted[i];
9752				const locale = ($('.userEL'+pid).hasClass('en')) ? 'en' : 'ko';
9753
9754				let sdate = ev.extendedProps?.start_date || '';
9755				let edate = ev.extendedProps?.end_date || '';
9756				let fulltimeFlag = ev.extendedProps?.fulltime; // 'Y' 또는 'N' 기대
9757
9758				const isAllDay = (fulltimeFlag === 'Y') || (!!ev.allDay);
9759
9760				if (!sdate && ev.start) sdate = toDateStr(ev.start);
9761
9762				if (!edate) {
9763					if (ev.end) {
9764						if (isAllDay) {
9765							const d = new Date(ev.end);
9766							d.setDate(d.getDate() - 1);
9767							edate = toDateStr(d);
9768						} else {
9769							edate = toDateStr(ev.end);
9770						}
9771					} else {
9772						edate = sdate; // 끝이 없으면 시작과 동일
9773					}
9774				}
9775
9776				let	schedule_time = '';
9777				if (sdate !== edate) {
9778					if (isAllDay) {
9779						schedule_time = `${sdate.slice(5)} ~ ${edate.slice(5)}`;
9780					} else {
9781						schedule_time = `${sdate.slice(5)} ${fmtHMFromDate(ev.start, locale)} ~ ${edate.slice(5)} ${fmtHMFromDate(ev.end, locale)}`;
9782					}
9783				} else {
9784					schedule_time = isAllDay ? '' : `${fmtHMFromDate(ev.start, locale)} ~ ${fmtHMFromDate(ev.end, locale)}`;
9785				}
9786
9787				const isFullLabel = isAllDay ? $.lang[locale]['config.calendar.fulltime'] : fmtHMFromDate(ev.start, locale);
9788				const isGoogle = !!ev.extendedProps?.isGoogle;
9789				const noTitleText = (locale === 'ko') ? '(제목 없음)' : '(No title)';
9790				const rawTitle = (typeof ev.title === 'string' && ev.title) || (ev._def && typeof ev._def.title === 'string' && ev._def.title) || (ev.extendedProps && typeof ev.extendedProps.summary === 'string' && ev.extendedProps.summary) || '';
9791				const titleSafe = rawTitle.trim() !== 'undefined' ? rawTitle : noTitleText;
9792				const bgColor = (() => {
9793					const own = ev.backgroundColor || ev.borderColor || '';
9794					if (isGoogle) {
9795						return own || googleColorHex || '#4789e7';
9796					}
9797					return own || '#4789e7';
9798				})();
9799
9800				modalHtml += `
9801					<li class="schedule-view" data-index="${i}">
9802					<div class="left-wrap">
9803						<input type="text" class="scheduleColorPicker color2"
9804						data-color="${bgColor}"
9805						style="background-color:${bgColor}" readonly>
9806						<span>${isFullLabel}</span>
9807					</div>
9808					<div class="right-wrap">
9809						<div class="schedule-title">${titleSafe} ${isGoogle ? '' : ''}</div>
9810						<div class="schedule-time">${schedule_time}</div>
9811					</div>
9812					</li>
9813				`;
9814			}
9815
9816			modalHtml += `
9817								</ul>
9818							</div>
9819						</div>`;
9820			if (property.UMEMBER.check_adm || property.UMEMBER.check_uadm) {
9821				modalHtml += `<div class="schedule-plus-box">
9822								<button class="schedule-plus pc">${$.lang[locale]['config.calendar.schedule-plus']}</button>
9823                    			<button class="schedule-plus mobile"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M18 9h-7V2H9v7H2v2h7v7h2v-7h7V9z"/></svg></button>
9824							</div>`;
9825			}
9826			modalHtml += `</div></div>`;
9827
9828			const $modalWrapper = $('.userEL' + pid).find(".calendarModal");
9829			$modalWrapper.append(modalHtml);
9830			calendarOverlayIn(pid);
9831			$modalWrapper.find(".calendar-modal-overlay").fadeIn(200);
9832
9833			$modalWrapper.off('click', '.schedule-view').on('click', '.schedule-view', function () {
9834				const index = $(this).data('index');
9835				const eventData = sorted[index];
9836				currentEvent = eventData;
9837
9838				showCalendarModalView(pid, eventData, true); 
9839			});
9840
9841			$modalWrapper.off('click', '.schedule-plus').on('click', '.schedule-plus', function () {
9842				const year = weekday[0].getFullYear();
9843				const month = String(weekday[0].getMonth() + 1).padStart(2, '0');
9844				const day = String(weekday[0].getDate()).padStart(2, '0');
9845				var startDate = `${year}-${month}-${day} 12:00`;
9846				var endDate = `${year}-${month}-${day} 13:00`;
9847				var date = [startDate, endDate];
9848				showCalendarModalEdit(pid, 0, date);
9849			});
9850		}
9851
9852		// function openMoreEventsModal(pid, events, weekday) {
9853		// 	var locale = ($('.userEL'+pid).hasClass('en')) ? 'en' : 'ko';
9854		// 	if (!Array.isArray(events)) {
9855		// 		events = [events];
9856		// 	}
9857
9858		// 	lastEventsList = events;
9859		// 	lastEventsWeekday = weekday;
9860		// 	const dayNum = weekday[0].getDate();
9861
9862		// 	const filteredEvents = events.filter(ev => !(ev.classNames && ev.classNames.includes('holiday-event')));
9863
9864		// 	const sorted = filteredEvents.slice().sort((a, b) => {
9865		// 		const isMulti = (ev) => {
9866		// 			const sd = ev.extendedProps?.start_date;
9867		// 			const ed = ev.extendedProps?.end_date;
9868		// 			if (sd && ed && sd !== ed) return true; 
9869		// 			if (ev.allDay && ev.start && ev.end) return (ev.end - ev.start) >= 86400000;
9870		// 			return false;
9871		// 		};
9872
9873		// 		const am = isMulti(a), bm = isMulti(b);
9874		// 		if (am !== bm) return am ? -1 : 1;   
9875
9876		// 		const as = a.start ? a.start.getTime() : 0;
9877		// 		const bs = b.start ? b.start.getTime() : 0;
9878		// 		if (as !== bs) return as - bs;
9879
9880		// 		const ae = a.end ? a.end.getTime() : Number.POSITIVE_INFINITY;
9881		// 		const be = b.end ? b.end.getTime() : Number.POSITIVE_INFINITY;
9882		// 		if (ae !== be) return ae - be;
9883
9884		// 		return (a.title || '').localeCompare(b.title || '');
9885		// 	});
9886
9887		// 	$(".calendar-modal-overlay").remove();
9888		// 	let modalHtml = `
9889		// 		<div class="calendar-modal-overlay" style="display:none;">
9890		// 			<div class="calendar-modal-container">
9891		// 				<div class="calendar-modal-header">
9892		// 					<h4>${dayNum} <span>${weekday[1]}</span></h4>
9893		// 					<button class="modal-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M17.85 17.15 10.7 10l7.15-7.15c.2-.19.2-.51.01-.71-.19-.2-.51-.2-.71-.01l-.01.01-7.15 7.15-7.14-7.14a.504.504 0 0 0-.71.01c-.19.19-.19.5 0 .69L9.29 10l-7.15 7.15c-.2.19-.2.51-.01.71.19.2.51.2.71.01l.01-.01L10 10.71l7.15 7.15c.19.2.51.2.71.01.2-.19.2-.51.01-.71l-.01-.01Z"/></svg></button>
9894		// 				</div>
9895		// 				<div class="calendar-modal-body">
9896		// 					<input type="hidden" id='sale-start-datetime' value="">
9897		// 					<div class="schedule-list">
9898		// 						<ul>
9899		// 	`;
9900
9901		// 	for (let i = 0; i < sorted.length; i++) {
9902		// 		var ev = sorted[i],
9903		// 			sdate = ev.extendedProps.start_date,
9904		// 			edate = ev.extendedProps.end_date,
9905		// 			schedule_time = '';
9906		// 		if(sdate != edate) {
9907		// 			schedule_time = sdate.split('-')[1] + '.' + sdate.split('-')[2] + ' ' + formatTime(ev.extendedProps.s_time, locale) +' ~ ' + edate.split('-')[1] + '.' + edate.split('-')[2] + ' ' + formatTime(ev.extendedProps.e_time, locale);
9908		// 		} else {
9909		// 			schedule_time = (ev.extendedProps.fulltime == 'Y') ? '' : `${formatTime(ev.extendedProps.s_time, locale)} ~ ${formatTime(ev.extendedProps.e_time, locale)}`;
9910		// 		}
9911		// 		const isFull = (ev.extendedProps.fulltime == 'Y') ? $.lang[locale]['config.calendar.fulltime'] : formatTime(ev.extendedProps.s_time, locale);
9912
9913		// 		modalHtml += `
9914		// 			<li class="schedule-view" data-index="${i}">
9915		// 				<div class="left-wrap">
9916		// 					<input type="text" class="scheduleColorPicker color2"
9917		// 						data-color="${ev.backgroundColor}"
9918		// 						style="background-color: ${ev.backgroundColor}" readonly>
9919		// 					<span>${isFull}</span>
9920		// 				</div>
9921		// 				<div class="right-wrap">
9922		// 					<div class="schedule-title">${ev._def.title}</div>
9923		// 					<div class="schedule-time">
9924		// 						${schedule_time}
9925		// 					</div>
9926		// 				</div>
9927		// 			</li>
9928		// 		`;
9929		// 	}
9930
9931		// 	modalHtml += `
9932		// 						</ul>
9933		// 					</div>
9934		// 				</div>`;
9935		// 	if (property.UMEMBER.check_adm || property.UMEMBER.check_uadm) {
9936		// 		modalHtml += `<div class="schedule-plus-box">
9937		// 						<button class="schedule-plus pc">${$.lang[locale]['config.calendar.schedule-plus']}</button>
9938        //             			<button class="schedule-plus mobile"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20"><path d="M18 9h-7V2H9v7H2v2h7v7h2v-7h7V9z"/></svg></button>
9939		// 					</div>`;
9940		// 	}
9941		// 	modalHtml += `</div></div>`;
9942
9943		// 	const $modalWrapper = $('.userEL' + pid).find(".calendarModal");
9944		// 	$modalWrapper.append(modalHtml);
9945		// 	calendarOverlayIn(pid);
9946		// 	$modalWrapper.find(".calendar-modal-overlay").fadeIn(200);
9947
9948		// 	$modalWrapper.off('click', '.schedule-view').on('click', '.schedule-view', function () {
9949		// 		const index = $(this).data('index');
9950		// 		const eventData = sorted[index];
9951		// 		currentEvent = eventData;
9952
9953		// 		showCalendarModalView(pid, eventData, true); 
9954		// 	});
9955
9956		// 	$modalWrapper.off('click', '.schedule-plus').on('click', '.schedule-plus', function () {
9957		// 		const year = weekday[0].getFullYear();
9958		// 		const month = String(weekday[0].getMonth() + 1).padStart(2, '0');
9959		// 		const day = String(weekday[0].getDate()).padStart(2, '0');
9960		// 		var startDate = `${year}-${month}-${day} 12:00`;
9961		// 		var endDate = `${year}-${month}-${day} 13:00`;
9962		// 		var date = [startDate, endDate];
9963		// 		showCalendarModalEdit(pid, 0, date);
9964		// 	});
9965		// }
9966
9967		function buildFcEvents(events) {
9968			function addDaysStr(ymd, days) {
9969				// ymd가 없거나 이상하면 오늘을 기준으로 보정
9970				if (!ymd || typeof ymd !== 'string' || ymd.length < 8) {
9971				const t = new Date();
9972				t.setDate(t.getDate() + (days || 0));
9973				const yy = t.getFullYear();
9974				const mm = String(t.getMonth() + 1).padStart(2, '0');
9975				const dd = String(t.getDate()).padStart(2, '0');
9976				return `${yy}-${mm}-${dd}`;
9977				}
9978				const [y, m, d] = ymd.split('-').map(Number);
9979				const dt = new Date((y || new Date().getFullYear()), (m ? m - 1 : 0), (d || 1));
9980				dt.setDate(dt.getDate() + (days || 0));
9981				const yy = dt.getFullYear();
9982				const mm = String(dt.getMonth() + 1).padStart(2, '0');
9983				const dd = String(dt.getDate()).padStart(2, '0');
9984				return `${yy}-${mm}-${dd}`;
9985			}
9986
9987			// 허용: "9:05", "23:45", "23:45:00" (앞뒤 공백 허용)
9988			const TIME_RX = /^\s*\d{1,2}:\d{2}(?::\d{2})?\s*$/;
9989			const toHM = (t) => {
9990				if (!t || typeof t !== 'string') return '00:00';
9991				const parts = t.trim().split(':');   // ["HH","mm"] 또는 ["HH","mm","ss"]
9992				const Hn = parseInt(parts[0], 10);
9993				const Mn = parseInt(parts[1] ?? '0', 10);
9994				const HH = isFinite(Hn) ? String(Hn).padStart(2, '0') : '00';
9995				const MM = isFinite(Mn) ? String(Mn).padStart(2, '0') : '00';
9996				return `${HH}:${MM}`;
9997			};
9998
9999			const mapped = (events || []).map(e => {
10000				let settings = {};
10001				try { settings = JSON.parse(e?.settings || '{}'); } catch {}
10002
10003				const isHoliday = e?.seq && String(e.seq).startsWith('holiday_');
10004
10005				// 날짜 확보: s_date/e_date → start/end → 오늘
10006				let sDate = (e?.s_date || '').slice(0, 10);
10007				let eDate = (e?.e_date || '').slice(0, 10);
10008
10009				if (!sDate && typeof e?.start === 'string') sDate = e.start.slice(0, 10);
10010				if (!eDate && typeof e?.end   === 'string') eDate = e.end.slice(0, 10);
10011				if (!sDate) {
10012				const t = new Date();
10013				sDate = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(t.getDate()).padStart(2, '0')}`;
10014				}
10015				if (!eDate) eDate = sDate;
10016
10017				// 시간 정규화
10018				const sHasTime = TIME_RX.test(e?.s_time || '');
10019				const eHasTime = TIME_RX.test(e?.e_time || '');
10020				const sTime = sHasTime ? toHM(e.s_time) : '00:00';
10021				const eTime = eHasTime ? toHM(e.e_time) : (sHasTime ? toHM(e.s_time) : '00:00');
10022
10023				// fulltime 플래그
10024				const fullTFlag = (e?.fulltime === 'Y');
10025
10026				// 시간이 둘 다 있으면 무조건 timed, 아니면 fullTFlag/날짜 범위로 all-day
10027				const isTimed = (sHasTime && eHasTime) && !fullTFlag;
10028				const fullT = !isTimed && (fullTFlag || sDate < eDate);
10029
10030				// ── 공휴일(배경)
10031				if (isHoliday) {
10032				const endPlus1 = addDaysStr(eDate, 1);
10033				return {
10034					id: `holiday_${sDate}_${settings.title || e.title}`,
10035					title: e?.title || settings.title || '',
10036					start: `${sDate}T00:00`,
10037					end:   `${endPlus1}T00:00`,
10038					allDay: true,
10039					display: 'background',
10040					classNames: ['holiday-event'],
10041					start_date: sDate,
10042					end_date: eDate,
10043				};
10044				}
10045
10046				let startISO, endISO, allDayFlag;
10047
10048				if (isTimed) {
10049					allDayFlag = false;
10050					startISO = `${sDate}T${sTime}`;
10051					endISO   = `${eDate}T${eTime}`;
10052
10053					// Invalid Date 방지: 유효하지 않으면 보정
10054					let s = new Date(startISO);
10055					let t = new Date(endISO);
10056					if (isNaN(s.getTime())) s = new Date(`${sDate}T00:00`);
10057					if (isNaN(t.getTime())) t = new Date(`${eDate}T${eTime || '00:00'}`);
10058
10059					// end < start → 동일 시각(0-duration)
10060					if (t.getTime() < s.getTime()) t = new Date(s.getTime());
10061
10062					// 같은 날짜인데 end가 다음날 00:00 경계로 넘어가면 23:59로 클램프
10063					const sameYMD = (a, b) => a.getFullYear()===b.getFullYear() && a.getMonth()===b.getMonth() && a.getDate()===b.getDate();
10064					if (!sameYMD(s, t) && sDate === eDate && t.getHours() === 0 && t.getMinutes() === 0) {
10065						t = new Date(s); t.setHours(23, 59, 0, 0);
10066					}
10067
10068					// (선택) 0-duration 렌더 꼬임 방지 +1분
10069					if (t.getTime() === s.getTime()) t = new Date(t.getTime() + 60 * 1000);
10070
10071					// ISO 재조립
10072					const yy = t.getFullYear();
10073					const mm = String(t.getMonth() + 1).padStart(2, '0');
10074					const dd = String(t.getDate()).padStart(2, '0');
10075					const HH = String(t.getHours()).padStart(2, '0');
10076					const MI = String(t.getMinutes()).padStart(2, '0');
10077					endISO = `${yy}-${mm}-${dd}T${HH}:${MI}`;
10078				} else {
10079					// all-day: end는 익스클루시브(+1일)
10080					allDayFlag = true;
10081					startISO = `${sDate}T00:00`;
10082					const endPlus1 = addDaysStr(eDate, 1);
10083					endISO   = `${endPlus1}T00:00`;
10084				}
10085
10086				const isMulti = (sDate && eDate && sDate !== eDate) || (allDayFlag && sDate !== eDate);
10087
10088				return {
10089				title: e?.title || settings.title || '',
10090				start: startISO,
10091				end:   endISO,
10092				allDay: allDayFlag,
10093				color: settings.color || '#4789e7',
10094				multiOrder: isMulti ? 0 : 1,
10095				memo: e?.memo,
10096				pid: e?.pid,
10097				seq: e?.seq,
10098				s_time: e?.s_time,
10099				e_time: e?.e_time,
10100				start_date: sDate,
10101				end_date: eDate,
10102				fulltime: e?.fulltime,
10103				classNames: []
10104				};
10105			});
10106
10107			// 인터페이스 유지
10108			// console.log(calendarElsettings)
10109			let pid = null;
10110
10111			if (Array.isArray(events) && events.length > 0) {
10112				pid = events[0].pid || null;
10113			}
10114
10115			const calendarFlag = (pid && calendarElsettings.get(pid) === true);
10116			return calendarFlag ? mapped : mapped.filter(ev => ev.classNames.includes('holiday-event'));
10117		}
10118
10119		function getClickedDateStrAccurate(info) {
10120			const stack = (info.jsEvent && document.elementsFromPoint)
10121				? document.elementsFromPoint(info.jsEvent.clientX, info.jsEvent.clientY)
10122				: [];
10123
10124			const cell = stack.find(el => el && el.getAttribute && el.getAttribute('data-date'));
10125
10126			if (cell) return cell.getAttribute('data-date');
10127
10128			const byClosest = info.el.closest('.fc-daygrid-day[data-date], .fc-timegrid-col[data-date], [data-date]');
10129			if (byClosest) return byClosest.getAttribute('data-date');
10130
10131			return (info.event.startStr || '').split('T')[0];
10132		}
10133
10134		function ymKey(d){ return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}`; }
10135
10136		function ymAdd(ym, delta) {
10137			const [y, m] = ym.split('-').map(Number);
10138			const n = y * 12 + (m - 1) + delta;
10139			const yy = Math.floor(n / 12), mm = (n % 12) + 1;
10140			return `${yy}-${String(mm).padStart(2, '0')}`;
10141		}
10142
10143		function monthsBetweenInclusive(sYmd, eYmd) {
10144			const out = [];
10145			const [sy, sm] = sYmd.split('-').map(Number);
10146			const [ey, em] = eYmd.split('-').map(Number);
10147			let y = sy, m = sm;
10148			while (y < ey || (y === ey && m <= em)) {
10149				out.push(`${y}-${String(m).padStart(2, '0')}`);
10150				m++;
10151				if (m === 13) { m = 1; y++; }
10152			}
10153			return out;
10154		}
10155
10156		function invalidateAround(pid, ym) { // ym: 'YYYY-MM'
10157			const pidMap = monthCache.get(pid);
10158			if (!pidMap) return;
10159
10160			const [y, m] = ym.split('-').map(Number);
10161			const prev = new Date(y, m - 2, 1);
10162			const cur  = new Date(y, m - 1, 1);
10163			const next = new Date(y, m, 1);
10164
10165			[prev, cur, next].forEach(d => {
10166				const key = `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}`;
10167				pidMap.delete(key);
10168			});
10169		}
10170
10171		// 서버에서 내려온 3개월치 data를 달별로 분배해서 병합
10172		function upsertMonthCacheFromServer(pid, serverEvents) {
10173			if (!serverEvents) return;
10174			let pidMap = monthCache.get(pid);
10175			if (!pidMap) {
10176				pidMap = new Map();
10177				monthCache.set(pid, pidMap);
10178			}
10179
10180			const mapped = buildFcEvents(serverEvents) || [];  // ★ 동일 포맷으로 맞춤
10181			const bucket = new Map(); // key: 'YYYY-MM' -> ev[]
10182			for (const ev of mapped) {
10183				// 시작/끝 계산 (all-day 및 00:00 경계 보정)
10184				const s0 = new Date(ev.start);
10185				const e0 = new Date(ev.end);
10186				const s  = new Date(s0);
10187				const e  = new Date(e0);
10188
10189				// 종일(Y) 또는 end가 00:00:00인 경우 표시용 inclusive 보정
10190				if (ev.fulltime === 'Y' || ev.allDay) {
10191				e.setDate(e.getDate() - 1);
10192				} else if (e0.getHours() === 0 && e0.getMinutes() === 0 && e0.getSeconds() === 0) {
10193				e.setMilliseconds(e.getMilliseconds() - 1);
10194				}
10195
10196				const cur = new Date(s.getFullYear(), s.getMonth(), 1);
10197				const last = new Date(e.getFullYear(), e.getMonth(), 1);
10198				while (cur <= last) {
10199				const key = ymKey(cur);
10200				if (!bucket.has(key)) bucket.set(key, []);
10201				bucket.get(key).push(ev);
10202				cur.setMonth(cur.getMonth() + 1);
10203				}
10204			}
10205
10206			for (const [key, arr] of bucket.entries()) {
10207				const prev = pidMap.get(key) || [];
10208				const seen = new Set();
10209				const merged = [];
10210				for (const item of [...prev, ...arr]) {
10211				const k = `${item.id || item.seq || item.title}|${item.start}|${item.end}|${item.allDay ? 1 : 0}`;
10212				if (!seen.has(k)) { seen.add(k); merged.push(item); }
10213				}
10214				pidMap.set(key, merged);
10215			}
10216		}
10217
10218		function monthsAround(ym) {
10219			const [y, m] = ym.split('-').map(Number);
10220			const prev = new Date(y, m - 2, 1);
10221			const cur  = new Date(y, m - 1, 1);
10222			const next = new Date(y, m, 1);
10223			return [prev, cur, next].map(d => `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}`);
10224		}
10225
10226		// 전/당/다음 달 캐시 무효화
10227		function invalidateAround(pid, ym) {
10228			const pidMap = monthCache.get(pid);
10229			if (!pidMap) return;
10230
10231			const [y, m] = ym.split('-').map(Number);
10232			const prev = new Date(y, m - 2, 1);  // 전월
10233			const cur  = new Date(y, m - 1, 1);  // 당월
10234			const next = new Date(y, m, 1);      // 다음월
10235
10236			[prev, cur, next].forEach(d => {
10237				const key = `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}`;
10238				pidMap.delete(key);
10239			});
10240		}
10241
10242		function monthsInRange(start, end){
10243			const arr = [];
10244			const d = new Date(start.getFullYear(), start.getMonth(), 1);
10245			while (d <= end) { arr.push(ymKey(d)); d.setMonth(d.getMonth()+1); }
10246			return arr;
10247		}
10248
10249		// 세 달(전월/해당월/다음월)을 한 번에 받아 캐시에 분산 저장
10250		function fetchMonth(pid, yearMonth, data_type) {
10251			let pidCache = monthCache.get(pid);
10252			let pidInflight = inflight.get(pid);
10253			if (!pidCache) { pidCache = new Map(); monthCache.set(pid, pidCache); }
10254			if (!pidInflight) { pidInflight = new Map(); inflight.set(pid, pidInflight); }
10255
10256			// 이미 캐시되어 있으면 재사용
10257			if (pidCache.has(yearMonth)) return Promise.resolve(pidCache.get(yearMonth));
10258			// 동일 YM에 대한 진행중 요청이 있으면 그것을 공유
10259			if (pidInflight.has(yearMonth)) return pidInflight.get(yearMonth);
10260
10261			const prevYM = ymAdd(yearMonth, -1);
10262			const nextYM = ymAdd(yearMonth, +1);
10263
10264			// 🔹 병합 유틸
10265			const dedupe = (list) => {
10266				const seen = new Set();
10267				const out = [];
10268				for (const ev of list) {
10269				const k = `${ev.id || ev.seq || ev.title}|${ev.start}|${ev.end}|${ev.allDay ? 1 : 0}`;
10270				if (!seen.has(k)) { seen.add(k); out.push(ev); }
10271				}
10272				return out;
10273			};
10274			const mergeSet = (cache, ym, arr) => {
10275				const prev = cache.get(ym) || [];
10276				const merged = dedupe(prev.concat(arr || []));
10277				cache.set(ym, merged);
10278			};
10279
10280			const p = new Promise((resolve, reject) => {
10281				$.ajax({
10282				url: '/template/get_calendar',
10283				type: 'POST',
10284				dataType: 'json',
10285				data: { sid: b.SID, pid, yearMonth, data_type },
10286				success: function(raw) {
10287					checkError(raw);
10288					// 서버 → FC 이벤트로 변환
10289					const all = buildFcEvents(raw) || [];
10290
10291					// 🔹 월 버킷팅
10292					const buckets = new Map();
10293					const put = (ym, ev) => {
10294					if (!buckets.has(ym)) buckets.set(ym, []);
10295					buckets.get(ym).push(ev);
10296					};
10297
10298					for (const ev of all) {
10299					const sStr = ev.start_date || (ev.start?.slice(0, 10)) || '';
10300					let eStr   = ev.end_date   || '';
10301
10302					if (!sStr) continue;
10303
10304					// end 보정 (종일: exclusive → inclusive / 00:00 경계 보정)
10305					if (!eStr) {
10306						if (ev.allDay && ev.end) eStr = addDaysStr(ev.end.slice(0, 10), -1);
10307						else if (ev.end)         eStr = ev.end.slice(0, 10);
10308						else                     eStr = sStr;
10309					} else {
10310						// 선택: 서버 end_date가 'YYYY-MM-DD' 00:00:00 의미라면 하루 빼기
10311						// 만약 서버 end_date가 이미 inclusive라면 이 블록은 제거하세요.
10312						// (현재 로직은 allDay에서만 -1 처리하므로 그대로 두는 게 안전)
10313					}
10314
10315					// 🔹 s~e 사이 모든 YM 버킷에 푸시
10316					const sYM = sStr.slice(0, 7);
10317					const eYM = eStr.slice(0, 7);
10318					for (const ym of monthsBetweenInclusive(sYM, eYM)) {
10319						put(ym, ev);
10320					}
10321					}
10322
10323					// 🔹 set → mergeSet 로 변경 (덮어쓰기 금지)
10324					mergeSet(pidCache, prevYM,   buckets.get(prevYM));
10325					mergeSet(pidCache, yearMonth, buckets.get(yearMonth));
10326					mergeSet(pidCache, nextYM,   buckets.get(nextYM));
10327
10328					// inflight 해제 (요청 공유했던 3개월 키 모두 제거)
10329					pidInflight.delete(prevYM);
10330					pidInflight.delete(yearMonth);
10331					pidInflight.delete(nextYM);
10332
10333					resolve(pidCache.get(yearMonth));
10334				},
10335				error: function(xhr, status, err) {
10336					pidInflight.delete(prevYM);
10337					pidInflight.delete(yearMonth);
10338					pidInflight.delete(nextYM);
10339					reject(err);
10340				}
10341				});
10342			});
10343
10344			// 동일 요청 공유 (3개월 모두 같은 Promise 공유)
10345			pidInflight.set(prevYM, p);
10346			pidInflight.set(yearMonth, p);
10347			pidInflight.set(nextYM, p);
10348
10349			return p;
10350		}
10351
10352		function calendarShow(elsettings) {
10353			return (
10354				property.UMEMBER.check_adm == true || 
10355				property.UMEMBER.check_uadm == true || 
10356				elsettings.read_chmod == 'all' || 
10357				(elsettings.read_chmod == 'admin' && property.UMEMBER.check_adm == true) || 
10358				(elsettings.read_chmod == 'admin' && property.UMEMBER.check_uadm == true) || 
10359				(elsettings.read_chmod == 'member' && property.UMEMBER.check_login == true) 
10360			);
10361		}
10362
10363		// 주/일 캘린더 공휴일 추가
10364		function headerRoot(view) {
10365			if (view && view.calendar && view.calendar.el) return view.calendar.el;
10366			if (view && view.el) return view.el;
10367			return document;
10368		}
10369		function fmtDate(d) {
10370			const y = d.getFullYear();
10371			const m = String(d.getMonth() + 1).padStart(2, '0');
10372			const dd = String(d.getDate()).padStart(2, '0');
10373			return `${y}-${m}-${dd}`;
10374		}
10375		function stripTime(d) {
10376			if (!(d instanceof Date)) return null;
10377			return new Date(d.getFullYear(), d.getMonth(), d.getDate());
10378		}
10379		function clearHolidayHeaderLabels(view) {
10380			const root = headerRoot(view);
10381			const header = root.querySelector('.fc-col-header');
10382			if (!header) return;
10383			header.querySelectorAll('.holiday-label').forEach(n => n.remove());
10384			header.querySelectorAll('.fc-col-header-cell-cushion.holiday-box')
10385					.forEach(el => el.classList.remove('holiday-box'));
10386		}
10387		function addHolidayHeaderLabel(view, dateStr, title) {
10388			const root = headerRoot(view);
10389			const header = root.querySelector('.fc-col-header');
10390			if (!header) return;
10391
10392			const th = header.querySelector(`[data-date="${dateStr}"]`);
10393			if (!th) return;
10394
10395			const inner = th.querySelector('.fc-scrollgrid-sync-inner') || th;
10396
10397			const cushion =
10398				inner.querySelector('.fc-col-header-cell-cushion') ||
10399				th.querySelector('.fc-col-header-cell-cushion') ||
10400				inner; 
10401			if (cushion && !cushion.classList.contains('holiday-box')) {
10402				cushion.classList.add('holiday-box');
10403			}
10404
10405			const exists = Array.from(inner.querySelectorAll('.holiday-label'))
10406				.some(el => el.textContent === (title || ''));
10407			if (!exists) {
10408				const label = document.createElement('span');
10409				label.className = 'holiday-label';
10410				label.textContent = title || '';
10411				inner.appendChild(label);
10412			}
10413		}
10414		function isHolidayEvent(ev) {
10415			const classes = ev.classNames || ev.extendedProps?.classNames || [];
10416			const hasHoliday = Array.isArray(classes) ? classes.includes('holiday-event') : (typeof classes === 'string' && classes.indexOf('holiday-event') > -1);
10417			return hasHoliday && ev.display === 'background';
10418		}
10419		function rebuildHolidayHeaderLabels(calendar) {
10420			const view = calendar.view;
10421			const vt = view?.type;
10422			if (!(vt === 'timeGridWeek' || vt === 'timeGridDay')) {
10423				clearHolidayHeaderLabels(view);
10424				return;
10425			}
10426
10427			const visibleStart = stripTime(view.activeStart);
10428			const visibleEnd   = stripTime(view.activeEnd); 
10429			if (!visibleStart || !visibleEnd) return;
10430
10431			clearHolidayHeaderLabels(view);
10432
10433			const map = {}; 
10434
10435			calendar.getEvents().forEach(ev => {
10436				if (!isHolidayEvent(ev)) return;
10437
10438				const evStart = stripTime(ev.start);
10439				if (!evStart) return; 
10440
10441				let evEnd = stripTime(ev.end);
10442				if (!evEnd) {
10443					evEnd = new Date(evStart);
10444					evEnd.setDate(evEnd.getDate() + 1);
10445				}
10446
10447				const s = new Date(Math.max(evStart.getTime(), visibleStart.getTime()));
10448				const e = new Date(Math.min(evEnd.getTime(), visibleEnd.getTime()));
10449				if (s >= e) return;
10450
10451				for (let d = new Date(s); d < e; d.setDate(d.getDate() + 1)) {
10452				const dateStr = fmtDate(d);
10453				(map[dateStr] ||= new Set()).add(ev.title || '');
10454				}
10455			});
10456
10457			Object.entries(map).forEach(([dateStr, titles]) => {
10458				titles.forEach(title => addHolidayHeaderLabel(view, dateStr, title));
10459			});
10460		}
10461		function setupHolidayHeaderHooks(calendar) {
10462			let t;
10463			const refresh = () => {
10464				clearTimeout(t);
10465				t = setTimeout(() => requestAnimationFrame(() => {
10466				rebuildHolidayHeaderLabels(calendar);
10467				rebuildMonthHolidayBoxes(calendar);
10468				}), 30);
10469			};
10470
10471			calendar.on('datesSet',   refresh);
10472			calendar.on('eventAdd',   refresh);
10473			calendar.on('eventChange',refresh);
10474			calendar.on('eventRemove',refresh);
10475			calendar.on('loading', (isLoading) => { if (!isLoading) refresh(); });
10476
10477			requestAnimationFrame(refresh);
10478		}
10479		//월간 공휴일
10480		function clearMonthHolidayBoxes(view) {
10481		const root = headerRoot(view);
10482		if (!root) return;
10483		root.querySelectorAll('.fc-daygrid-day-top.holiday-box')
10484			.forEach(n => n.classList.remove('holiday-box'));
10485		}
10486
10487		function rebuildMonthHolidayBoxes(calendar) {
10488			const view = calendar.view;
10489			if (!view || !view.type.startsWith('dayGrid')) {
10490				clearMonthHolidayBoxes(view);
10491				return;
10492			}
10493
10494			const locale = calendar.getOption("locale");
10495			if (locale != "ko") {
10496				clearMonthHolidayBoxes(view);
10497				return;
10498			}
10499
10500			const visibleStart = stripTime(view.activeStart);
10501			const visibleEnd   = stripTime(view.activeEnd); 
10502			if (!visibleStart || !visibleEnd) return;
10503
10504			clearMonthHolidayBoxes(view);
10505
10506			const hasHolidayMap = {}; 
10507			calendar.getEvents().forEach(ev => {
10508				if (!isHolidayEvent(ev) || !ev.start) return;
10509
10510				const evStart = stripTime(ev.start);
10511				let evEnd     = stripTime(ev.end);
10512				if (!evEnd) { evEnd = new Date(evStart); evEnd.setDate(evEnd.getDate() + 1); }
10513
10514				const s = new Date(Math.max(evStart.getTime(), visibleStart.getTime()));
10515				const e = new Date(Math.min(evEnd.getTime(),   visibleEnd.getTime()));
10516				if (s >= e) return;
10517
10518				for (let d = new Date(s); d < e; d.setDate(d.getDate() + 1)) {
10519				hasHolidayMap[fmtDate(d)] = true;
10520				}
10521			});
10522
10523			const root = headerRoot(view);
10524			root.querySelectorAll('.fc-daygrid-day').forEach(td => {
10525				const dateStr = td.getAttribute('data-date');
10526				if (!dateStr) return;
10527				const top = td.querySelector('.fc-daygrid-day-top');
10528				if (!top) return;
10529				if (hasHolidayMap[dateStr]) top.classList.add('holiday-box');
10530			});
10531		}
10532
10533		function fmt(dt) {
10534			const y  = dt.getFullYear();
10535			const m  = String(dt.getMonth() + 1).padStart(2, '0');
10536			const d  = String(dt.getDate()).padStart(2, '0');
10537			const hh = String(dt.getHours()).padStart(2, '0');
10538			const mm = String(dt.getMinutes()).padStart(2, '0');
10539			return `${y}-${m}-${d} ${hh}:${mm}`;
10540		}
10541
10542		function toYMDLocal(d) {
10543			if (!d) return '';
10544			const yy = d.getFullYear();
10545			const mm = String(d.getMonth() + 1).padStart(2, '0');
10546			const dd = String(d.getDate()).padStart(2, '0');
10547			return `${yy}-${mm}-${dd}`;
10548		}
10549
10550
10551		function initCalendar(pid, c, retryCount = 0) {
10552			var c = (typeof c != 'undefined') ? c : '';
10553			// console.log(pid);
10554			const MAX_RETRIES = 5;
10555			var containerEl = document.querySelector('.userEL' + pid + ' .calendar-container');
10556			var lang = document.querySelector('.calendar[data-id="' + pid + '"]').classList.contains('en');
10557    
10558			var language = 'ko';
10559			if(lang) language = 'en';
10560			else language = 'ko';
10561
10562			if (!containerEl) {
10563				if (retryCount < MAX_RETRIES) {
10564					setTimeout(() => initCalendar(pid, c, retryCount + 1), 300);
10565				} else {
10566					console.warn('initCalendar: containerEl을 찾을 수 없어 초기화를 중단합니다.');
10567				}
10568				return;
10569			}
10570
10571			containerEl.innerHTML = '';
10572
10573			var calendarEl = document.createElement('div');
10574			calendarEl.id = 'fc-calendar-' + pid;
10575			containerEl.appendChild(calendarEl);
10576
10577			var instance = $.cl_calendar.instances[pid],
10578				maxEvent = parseInt(containerEl.getAttribute('data-view')),
10579				elsettings = '',
10580				view_mode = 'dayGridMonth'; // 기본값
10581
10582			elsettings = JSON.parse(c.elsettings);
10583			if(elsettings.open_mwd == 'month') view_mode = 'dayGridMonth';
10584			else if(elsettings.open_mwd == 'week') view_mode = 'timeGridWeek';
10585			else if(elsettings.open_mwd == 'day') view_mode = 'timeGridDay';
10586
10587			const color = elsettings.google_color ? elsettings.google_color.trim() : '#4789e7';
10588			googleColor.set(pid, color);
10589			// console.log(`pid:${pid} => color:${color}`);
10590
10591			if(view_mode == 'timeGridWeek' && window.innerWidth < 768) {
10592				view_mode = 'dayGridMonth';
10593			}
10594
10595			//구글캘린더 연동
10596			const googleShow = (calendarElsettings.get(pid) === true);
10597			const eventSources = [
10598				function(fetchInfo, success, failure) {
10599					const data_type = ($('.userEL' + pid).attr('data-modoo-type')) || '';
10600					const keys = monthsInRange(fetchInfo.start, fetchInfo.end); // YYYY-MM 배열
10601
10602					// 각 월을 fetchMonth로 보장(캐시가 있으면 내부에서 스킵하게 구현)
10603					Promise.all(
10604						keys.map(k => fetchMonth(pid, k, data_type))
10605					)
10606					.then(() => {
10607						// 캐시에서 해당 범위의 이벤트 전부 모으기
10608						const pidCache = monthCache.get(pid) || new Map();
10609						const all = [];
10610						keys.forEach(k => {
10611							const arr = pidCache.get(k);
10612							if (arr && arr.length) all.push(...arr);
10613						});
10614
10615						const src = all;
10616
10617						const seen = new Set();
10618						const uniq = [];
10619						for (const ev of src) {
10620							const key = `${ev.id || ev.seq || ev.title}|${ev.start}|${ev.end}|${ev.allDay ? 1 : 0}`;
10621							if (!seen.has(key)) {
10622								seen.add(key);
10623								uniq.push(ev);
10624							}
10625						}
10626
10627						success(uniq);
10628					})
10629					.catch(failure);
10630				}
10631			];
10632
10633			// ✅ 2️⃣ 조건문으로 구글 캘린더/공휴일 캘린더를 추가
10634			const userCalendarId = elsettings.google_id; // 사용자 입력 또는 DB값
10635			const google_color = elsettings.google_color;
10636			const holidayCalendarId = 'ko.south_korea#[email protected]';
10637			const apiKey = elsettings.google_api;
10638			const googleSyncOn = String(elsettings.google_sync || '0') === '1';
10639
10640			function fmtHHMM(date) {
10641				if (!date) return '';
10642				const hh = String(date.getHours()).padStart(2, '0');
10643				const mm = String(date.getMinutes()).padStart(2, '0');
10644				return `${hh}:${mm}`;
10645			}
10646
10647			if (googleSyncOn && userCalendarId && userCalendarId.trim() !== '' && apiKey && googleShow) {
10648				eventSources.push({
10649					// 🔹 gcal 플러그인 대신 직접 Google Calendar API 호출
10650					events: function(fetchInfo, success, failure) {
10651						const params = new URLSearchParams({
10652							key: apiKey,
10653							timeMin: fetchInfo.startStr,
10654							timeMax: fetchInfo.endStr,
10655							singleEvents: 'true',
10656							orderBy: 'startTime'
10657						});
10658
10659						const url = `https://www.googleapis.com/calendar/v3/calendars/${
10660							encodeURIComponent(userCalendarId)
10661						}/events?${params.toString()}`;
10662
10663						fetch(url)
10664							.then(res => {
10665								if (!res.ok) throw new Error('Google Calendar API error: ' + res.status);
10666								return res.json();
10667							})
10668							.then(data => {
10669								const items = data.items || [];
10670								const googleColorHex = google_color || '#4789e7';
10671
10672								const fcEvents = items
10673									.filter(ev => ev.visibility !== 'private')  // 비공개는 아예 제외
10674									.map(ev => {
10675										const isAllDay = !!ev.start.date;
10676										const startStr = ev.start.dateTime || ev.start.date;
10677										const endStr   = (ev.end && (ev.end.dateTime || ev.end.date)) || startStr;
10678
10679										const start = startStr ? new Date(startStr) : null;
10680										const end   = endStr   ? new Date(endStr)   : null;
10681
10682										let start_date = '',
10683											end_date   = '',
10684											s_time     = '',
10685											e_time     = '',
10686											fulltime   = isAllDay ? 'Y' : 'N',
10687											memo       = '';
10688
10689										if (start) {
10690										start_date = fmtDate(start);
10691
10692										if (isAllDay) {
10693											if (end) {
10694											const d = new Date(end);
10695											d.setDate(d.getDate() - 1);
10696											end_date = fmtDate(d);
10697											} else {
10698											end_date = start_date;
10699											}
10700											s_time = '';
10701											e_time = '';
10702										} else {
10703											end_date = end ? fmtDate(end) : start_date;
10704											s_time   = fmtHHMM(start);
10705											e_time   = end ? fmtHHMM(end) : '';
10706										}
10707										}
10708
10709										// 🔹 제목 없는 이벤트 처리
10710										const hasTitle = ev.summary && ev.summary.trim().length > 0;
10711										const title    = hasTitle ? ev.summary.trim() : (language == 'ko') ? '(제목 없음)' : '(No title)';
10712
10713										// description → memo
10714										memo = (ev.description && typeof ev.description === 'string')
10715										? ev.description
10716										: '';
10717
10718										const googleColorHex = google_color || '#4789e7';
10719
10720										return {
10721											id: ev.id,
10722											title,                 // ✅ 여기서 (제목 없음)까지 세팅
10723											start: startStr,
10724											end: endStr,
10725											allDay: isAllDay,
10726											backgroundColor: googleColorHex,
10727											borderColor: googleColorHex,
10728											extendedProps: {
10729												...ev,
10730												isGoogle: true,
10731												start_date,
10732												end_date,
10733												s_time,
10734												e_time,
10735												fulltime,
10736												memo,
10737												backgroundColor: googleColorHex
10738											}
10739										};
10740									});
10741
10742								success(fcEvents);
10743							})
10744							.catch(err => {
10745								console.error('Google Calendar fetch error', err);
10746								failure(err);
10747							});
10748					},
10749
10750					// 아래 옵션들은 그대로 유지해도 됨
10751					color: google_color || '#4789e7',
10752					className: 'personal-events'
10753				});
10754			}
10755
10756			var calendar = new FullCalendar.Calendar(calendarEl, {
10757				initialView: view_mode,
10758				eventSources: eventSources,
10759				locale: language,
10760				locales: [
10761					{
10762						code: 'en',
10763						buttonText: {
10764							today: 'Today',
10765							month: 'Month',
10766							week: 'Week',
10767							day: 'Day',
10768							list: 'List',
10769							// 뷰별로 더 구체화도 가능
10770							dayGridMonth: 'Month',
10771							timeGridWeek: 'Week',
10772							timeGridDay: 'Day',
10773							listWeek: 'List',
10774						}
10775						},
10776						{
10777						code: 'ko',
10778						buttonText: {
10779							today: '오늘',
10780							month: '월',
10781							week: '주',
10782							day: '일',
10783							list: '목록',
10784							dayGridMonth: '월',
10785							timeGridWeek: '주',
10786							timeGridDay: '일',
10787							listWeek: '목록',
10788						}
10789					}
10790				],
10791				selectable: true,
10792				fixedWeekCount: false,
10793				showNonCurrentDates: true,
10794				eventDisplay: 'block',
10795				contentHeight: 'auto',
10796				expandRows: true,
10797				headerToolbar: {
10798					left: 'dayGridMonth,timeGridWeek,timeGridDay',
10799					center: 'prev,title,next',
10800					right: 'today'
10801				},
10802				nowIndicator: true,
10803				windowResize: function(arg) {
10804					const cal = arg.view.calendar;
10805					const isWeek = arg.view.type === 'timeGridWeek';
10806					const w = window.innerWidth;
10807
10808					if (w <= 768 && isWeek) {
10809						cal.changeView('dayGridMonth');
10810					}
10811				},
10812				views: {
10813					dayGridMonth: {
10814						// dayMaxEventRows: maxEvent,
10815                		dayMaxEvents: maxEvent, 
10816						moreLinkDidMount: function(args) { args.el.removeAttribute('title'); },
10817						moreLinkContent: function(args) { 
10818							var locale = args.view.calendar.getOption("locale");
10819							if (locale === "ko") {
10820								return { html: `+${args.num}개<span class="more"> 더보기</span>` };
10821							} else {
10822								return { html: `+${args.num} <span class="more">more</span>` };
10823							}
10824						},
10825						moreLinkClick: function(info) {
10826							var locale = info.view.dateEnv.locale.codes[0];
10827							info.jsEvent.preventDefault();
10828							info.jsEvent.stopPropagation();
10829							const dateObj = info.date;
10830							var weekdayStr = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'][dateObj.getDay()];
10831							if(locale == 'ko') weekdayStr = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'][dateObj.getDay()];
10832							else weekdayStr = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][dateObj.getDay()];
10833							var weekday = [dateObj, weekdayStr];
10834							const events = info.allSegs.map(seg => seg.event);
10835
10836							openMoreEventsModal(pid, events, weekday);
10837
10838						},
10839					},
10840					timeGridWeek: {
10841						slotEventOverlap: false, 
10842						eventOverlap: false,
10843						eventMaxStack: 10,
10844                		moreLinkContent() { return { html: '' } },
10845						titleFormat: function(arg) {
10846							const start = new Date(arg.date.marker);
10847							const end = new Date(start);
10848							end.setDate(end.getDate() + 6);
10849							end.setHours(23, 59, 59, 999);
10850
10851							const now = new Date();
10852
10853							const baseDate = (now >= start && now <= end) ? now : start;
10854
10855							const locale = (arg.localeCodes && arg.localeCodes[0]) || "en";
10856
10857							if (locale === "ko") {
10858								const y = baseDate.getFullYear();
10859								const m = String(baseDate.getMonth() + 1).padStart(2, "0");
10860								return `${y}년 ${m}월`;
10861							} else {
10862								return new Intl.DateTimeFormat(locale, {
10863								month: "long",
10864								year: "numeric",
10865								}).format(baseDate);
10866							}
10867						},
10868						dayHeaderContent: function(arg) {
10869							var d = arg.date?.marker || arg.date;
10870							var locale = arg.view.dateEnv.locale.codes[0];
10871							if (locale == 'ko') {
10872								const dayNumber = d.getDate();
10873								const weekDayKo = new Intl.DateTimeFormat('ko', { weekday: 'short' }).format(d);
10874								return {
10875									html: `<span class="round">${dayNumber}</span> ${weekDayKo}`,
10876								};
10877							} else {
10878								const dayNumber = d.getDate();
10879								const weekDayEn = new Intl.DateTimeFormat('en', { weekday: 'short' }).format(d);
10880								return {
10881									html: `<span class="round">${dayNumber}</span> ${weekDayEn}`,
10882								};
10883							}
10884						}
10885					},
10886					timeGridDay: {
10887						slotEventOverlap: false, 
10888						eventOverlap: false,
10889						eventMaxStack: 10,
10890                		moreLinkContent() { return { html: '' } },
10891						titleFormat: { year: 'numeric', month: 'long' },
10892						dayHeaderContent: function(arg) {
10893							const dateObj = arg.date; 
10894							const dayNumber = dateObj.getDate(); 
10895
10896							var locale = arg.view.dateEnv.locale.codes[0];
10897							if (locale === "ko") {
10898								const weekNames = ["일", "월", "화", "수", "목", "금", "토"];
10899								const weekDay = weekNames[dateObj.getDay()];
10900								return {
10901									html: `<span class="round">${dayNumber}</span> ${weekDay}`,
10902								};
10903							} else {
10904								const weekDay = new Intl.DateTimeFormat("en", { weekday: "short" }).format(dateObj);
10905								return {
10906									html: `<span class="round">${dayNumber}</span> ${weekDay}`,
10907								};
10908							}
10909						}
10910					},
10911					timeGrid: {
10912                		allDayText: (!lang) ? '하루종일' : 'All day'
10913            		}
10914				},
10915				// events: function(fetchInfo, success, failure) {
10916				// 	const data_type = ($('.userEL' + pid).attr('data-modoo-type')) || '';
10917				// 	const keys = monthsInRange(fetchInfo.start, fetchInfo.end); // YYYY-MM 배열
10918
10919				// 	// 각 월을 fetchMonth로 보장(캐시가 있으면 내부에서 스킵하게 구현)
10920				// 	Promise.all(
10921				// 		keys.map(k =>
10921 fetchMonth(pid, k, data_type))
10922				// 	)
10923				// 	.then(() => {
10924				// 		// 캐시에서 해당 범위의 이벤트 전부 모으기
10925				// 		const pidCache = monthCache.get(pid) || new Map();
10926				// 		const all = [];
10927				// 		keys.forEach(k => {
10928				// 			const arr = pidCache.get(k);
10929				// 			if (arr && arr.length) all.push(...arr);
10930				// 		});
10931
10932				// 		const src = all;
10933
10934				// 		const seen = new Set();
10935				// 		const uniq = [];
10936				// 		for (const ev of src) {
10937				// 			const key = `${ev.id || ev.seq || ev.title}|${ev.start}|${ev.end}|${ev.allDay ? 1 : 0}`;
10938				// 			if (!seen.has(key)) {
10939				// 				seen.add(key);
10940				// 				uniq.push(ev);
10941				// 			}
10942				// 		}
10943
10944				// 		success(uniq);
10945				// 	})
10946				// 	.catch(failure);
10947				// },
10948				eventOrder: ['multiOrder', 'start', 'duration', 'title'],
10949				// eventOrder: 'start',
10950				eventDidMount: function(info) {
10951					// 구글 이벤트만 색 덧칠
10952					if (info.event.extendedProps?.isGoogle) {
10953						const col = (googleColor && googleColor.get(pid)) || '';
10954						if (col) {
10955							info.el.style.backgroundColor = col;
10956							info.el.style.borderColor = col;
10957
10958							// 월간 뷰의 작은 점에도 반영 (dot 모드일 경우)
10959							const dot = info.el.querySelector('.fc-daygrid-event-dot');
10960							if (dot) {
10961								dot.style.backgroundColor = col;
10962								dot.style.borderColor = col;
10963							}
10964						}
10965					}
10966
10967					if (info.event.display === 'background' && info.event.classNames.includes('holiday-event')) {
10968						const viewType = info.view.type;
10969						if (viewType === 'timeGridWeek' || viewType === 'timeGridDay') {
10970							const start = new Date(info.event.start);
10971							const end   = new Date(info.event.end);
10972							for (let d = new Date(start); d < end; d.setDate(d.getDate() + 1)) {
10973								const y = d.getFullYear();
10974								const m = String(d.getMonth() + 1).padStart(2, '0');
10975								const day = String(d.getDate()).padStart(2, '0');
10976								const dateStr = `${y}-${m}-${day}`;
10977								addHolidayHeaderLabel(info.view.el, dateStr, info.event.title || '');
10978							}
10979						}
10980
10981						const cell = info.el.closest('.fc-daygrid-day');
10982						if (cell) {
10983							const harnessCount = cell.querySelectorAll('.fc-daygrid-bg-harness').length;
10984							if (harnessCount > 1) {
10985								const labels = cell.querySelectorAll('.holiday-label');
10986								labels.forEach((label, idx) => { label.classList.add(`multi_${idx + 1}`); });
10987							}
10988						}
10989					}
10990
10991					if (info.event.extendedProps.seq) {
10992						info.el.setAttribute('data-seq', info.event.extendedProps.seq);
10993					}
10994
10995					const durationHours = (info.event.end - info.event.start) / (1000 * 60 * 60);
10996					if (durationHours > 1) {
10997						const afterDiv = document.createElement('div');
10998						afterDiv.classList.add('event-overlay');
10999						afterDiv.style.position = 'absolute';
11000						afterDiv.style.top = '50px'; 
11001						afterDiv.style.left = '0';
11002						afterDiv.style.right = '0';
11003						afterDiv.style.height = `calc(100% - 50px)`;
11004						// afterDiv.style.backgroundColor = '#4789e71a';
11005						afterDiv.style.pointerEvents = 'none';
11006						info.el.appendChild(afterDiv);
11007					}
11008				},
11009				dateClick: function(info) {
11010					// console.log('dateClick');
11011
11012					//현재시간기준 30분단위로 시작시간 설정
11013					const STEP_MIN = 30;
11014
11015					function ceilToNextSlot(base, stepMin) {
11016						const d = new Date(base);
11017						d.setSeconds(0,0);
11018						let m = d.getMinutes();
11019						const r = m % stepMin;
11020						if (r !== 0) m += (stepMin - r);
11021						else m += stepMin;
11022						if (m >= 60) { d.setHours(d.getHours()+1); m -= 60; }
11023						d.setMinutes(m);
11024						return d;
11025					}
11026
11027					const start = new Date(info.date);
11028					let time;
11029
11030					if (info.view.type === 'dayGridMonth') {
11031						const next = ceilToNextSlot(new Date(), STEP_MIN);
11032						const s = new Date(
11033							start.getFullYear(), start.getMonth(), start.getDate(),
11034							next.getHours(), next.getMinutes(), 0, 0
11035						);
11036						const e = new Date(s); e.setHours(e.getHours() + 1);
11037						time = [fmt(s), fmt(e), 0];
11038					} else {
11039						const s = new Date(info.start);
11040						const e = new Date(info.start); e.setMinutes(e.getMinutes() + 30);
11041						const isAllDay = (info.startStr.includes('T')) ? 0 : 1;
11042						time = isAllDay ? [info.startStr, info.startStr, 1] : [fmt(s), fmt(e), 0];
11043					}
11044					if(isMobile() && (property.UMEMBER.check_adm || property.UMEMBER.check_uadm))  showCalendarModalEdit(pid, 0, time);
11045				},
11046				select: function(info) {
11047					// console.log('select');
11048
11049					//현재시간기준 30분단위로 시작시간 설정
11050					const STEP_MIN = 30;
11051
11052					function ceilToNextSlot(base, stepMin) {
11053						const d = new Date(base);
11054						d.setSeconds(0,0);
11055						let m = d.getMinutes();
11056						const r = m % stepMin;
11057						if (r !== 0) m += (stepMin - r);
11058						else m += stepMin;
11059						if (m >= 60) { d.setHours(d.getHours()+1); m -= 60; }
11060						d.setMinutes(m);
11061						return d;
11062					}
11063
11064					const start = new Date(info.start);
11065					let time;
11066
11067					if (info.view.type === 'dayGridMonth') {
11068						const next = ceilToNextSlot(new Date(), STEP_MIN); 
11069						const s = new Date(
11070							start.getFullYear(), start.getMonth(), start.getDate(),
11071							next.getHours(), next.getMinutes(), 0, 0
11072						);
11073						const e = new Date(s); e.setHours(e.getHours() + 1);
11074						time = [fmt(s), fmt(e), 0];
11075					} else {
11076						const s = new Date(info.start);
11077						const e = new Date(info.start); e.setMinutes(e.getMinutes() + 30);
11078						const isAllDay = (info.startStr.includes('T')) ? 0 : 1;
11079						time = isAllDay ? [info.startStr, info.startStr, 1] : [fmt(s), fmt(e), 0];
11080					}
11081					if(!isMobile() && property.UMEMBER.check_adm || property.UMEMBER.check_uadm) showCalendarModalEdit(pid, 0, time);
11082				},
11083				eventClick: function(info) {
11084					info.jsEvent.preventDefault();
11085            		info.jsEvent.stopPropagation();
11086					var locale = info.view.dateEnv.locale.codes[0];
11087					const clickedDateStr = getClickedDateStrAccurate(info);
11088					const clickedDate = new Date(clickedDateStr);
11089					var weekdayStr = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'][clickedDate.getDay()];
11090					if(locale == 'ko') weekdayStr = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'][clickedDate.getDay()];
11091					else weekdayStr = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][clickedDate.getDay()];
11092					const weekday = [clickedDate, weekdayStr];
11093
11094					const calendar = info.view.calendar;
11095					const allEvents = calendar.getEvents();
11096
11097					const eventsOnSameDay = allEvents.filter(ev => {
11098
11099						const isGoogle = !!ev.extendedProps?.isGoogle;
11100
11101						if (isGoogle) {
11102							// ---- 구글 이벤트 전용 날짜 계산 (로컬 기준) ----
11103							const s = ev.start ? new Date(ev.start) : null;
11104							let   e = ev.end   ? new Date(ev.end)   : null;
11105
11106							if (!s) return false;
11107
11108							// end 없으면 start와 같은 날로 취급
11109							if (!e) e = new Date(s);
11110
11111							// allDay 인 경우, FullCalendar는 end를 "exclusive"로 쓰므로 마지막 날 = end - 1일
11112							if (ev.allDay && ev.end) {
11113								e.setDate(e.getDate() - 1);
11114							}
11115
11116							const startStr = toYMDLocal(s);   // ✅ 로컬 날짜
11117							const endStr   = toYMDLocal(e);   // ✅ 로컬 날짜
11118
11119							return (clickedDateStr >= startStr && clickedDateStr <= endStr);
11120						}
11121
11122						// ---- 기존(내부) 이벤트 로직 그대로 유지, 날짜 계산만 toYMDLocal로 정리 ----
11123						const startStrBase = (ev.extendedProps.start_date || ev.startStr || '').split('T')[0];
11124
11125						let startStr = startStrBase;
11126						if (!startStr && ev.start) {
11127							startStr = toYMDLocal(ev.start);   // 안전장치
11128						}
11129
11130						let endInclStr;
11131						if (ev.extendedProps.end_date) {
11132							endInclStr = ev.extendedProps.end_date;
11133						} else if (ev.allDay) {
11134							if (ev.end) {
11135								const dayDiff = Math.ceil((ev.end - ev.start) / 86400000);
11136								if (dayDiff >= 2) {
11137									const d = new Date(ev.end);
11138									d.setDate(d.getDate() - 1);
11139									endInclStr = toYMDLocal(d);     // ✅ 여기서도 toISOString 대신 로컬
11140								} else {
11141									endInclStr = startStr;
11142								}
11143							} else {
11144								endInclStr = startStr;
11145							}
11146						} else if (ev.end) {
11147							// timed 이벤트는 endStr도 로컬 기준으로
11148							endInclStr = toYMDLocal(ev.end);
11149						} else {
11150							endInclStr = startStr;
11151						}
11152
11153						return clickedDateStr >= startStr && clickedDateStr <= endInclStr;
11154					});
11155
11156					openMoreEventsModal(pid, eventsOnSameDay, weekday);
11157				},
11158				eventContent: function(arg) {
11159					var locale = arg.view.dateEnv.locale.codes[0];
11160					const noTitleText = (locale === 'ko') ? '(제목 없음)' : '(No title)';
11161
11162					if (arg.event.classNames.includes('holiday-event')) {
11163						if (locale === 'ko') {
11164							const titleText = (arg.event.title && arg.event.title.trim() !== '') ? arg.event.title : noTitleText;
11165							return { html: `<div class="holiday-label">${titleText}</div>` };
11166						} else {
11167							return { html: '' };
11168						}
11169					}
11170
11171					const cal = arg.view.calendar;
11172					let timeText = '';
11173
11174					if (!arg.event.allDay) {
11175						const start = arg.event.start;
11176						const end = arg.event.end;
11177						const fmtOpts = {
11178							hour: 'numeric',
11179							minute: '2-digit',
11180							meridiem: 'short',
11181							hour12: true
11182						};
11183
11184						if (end && end.getTime() !== (start?.getTime() ?? 0)) {
11185							timeText = cal.formatRange(start, end, fmtOpts);
11186						} else if (start) {
11187							timeText = cal.formatDate(start, fmtOpts);
11188						}
11189					}
11190
11191					const rawTitle = (typeof arg.event.title === 'string') ? arg.event.title : '';
11192					const titleText = rawTitle.trim() !== 'undefined' ? rawTitle : noTitleText;
11193
11194					return {
11195						html: `
11196						<div class="fc-event-custom">
11197							<div class="fc-event-title">${titleText}</div>
11198							${timeText ? `<div class="fc-event-time">${timeText}</div>` : ''}
11199						</div>
11200						`
11201					};
11202				},
11203				dayCellContent: function(arg) { return arg.date.getDate(); },
11204				dayCellDidMount: function(arg) {
11205					// const dayEvents = arg.view.calendar.getEvents().filter(event => {
11206					// 	return moment(event.start).format('YYYY-MM-DD') === moment(arg.date).format('YYYY-MM-DD') 
11207					// 		&& event.classNames.includes('holiday-event');
11208					// });
11209
11210					// if (dayEvents.length > 0) {
11211					// 	const eventsContainer = arg.el.querySelector('.fc-daygrid-day-top');
11212					// 	if (eventsContainer) {
11213					// 	eventsContainer.classList.add('holiday-box');
11214					// 	}
11215					// }
11216				},
11217				datesSet: function(arg) {
11218					clearHolidayHeaderLabels(arg.view.el);
11219
11220					if (arg.view.type === 'timeGridWeek' || arg.view.type === 'timeGridDay') {
11221						const events = arg.view.calendar.getEvents().filter(ev =>
11222						ev.display === 'background' && ev.classNames.includes('holiday-event')
11223						);
11224						for (const ev of events) {
11225							const start = new Date(ev.start);
11226							const end   = new Date(ev.end);
11227							for (let d = new Date(start); d < end; d.setDate(d.getDate() + 1)) {
11228								const y = d.getFullYear();
11229								const m = String(d.getMonth() + 1).padStart(2, '0');
11230								const day = String(d.getDate()).padStart(2, '0');
11231								addHolidayHeaderLabel(arg.view.el, `${y}-${m}-${day}`, ev.title || '');
11232							}
11233						}
11234					}
11235				}
11236			});
11237
11238			calendar.on('datesSet', (arg) => { //월 초기 노출 개수
11239				// ▼ 부족 월 프리페치 (prev/next 이동 시 캐시에 없는 달만 보충)
11240				if (!calendar.__prefetching) {
11241					const keys = monthsInRange(arg.start, arg.end); // ['YYYY-MM', ...]
11242					const pidMap = monthCache.get(pid) || new Map();
11243					const missing = keys.filter(k => !pidMap.has(k));
11244
11245					if (missing.length) {
11246						calendar.__prefetching = true;
11247						const dt = ($('.userEL'+pid).attr('data-modoo-type')) || '';
11248						Promise.all(missing.map(k => fetchMonth(pid, k, dt)))
11249						.then(() => arg.view.calendar.refetchEvents())
11250						.finally(() => { calendar.__prefetching = false; });
11251					}
11252				}
11253			});
11254
11255			calendar.render();
11256			setupHolidayHeaderHooks(calendar);
11257			$.cl_calendar.instances[pid].calendar = calendar;
11258
11259			$(`[data-type="calendar"][data-id="${pid}"]`).addClass('_calendar');
11260		}//calendar end
11261
11262		// $('.gallery-item').live('click', function(e) {
11263		// 	if($(this).find('[attr-flink]').length > 0 ) {
11264		// 		e.preventDefault();
11265		// 		return false;
11266		// 	}
11267
11268		// 	if($(e.target).hasClass('like') || $(e.target).closest('.figure').hasClass('like')) {
11269		//         e.preventDefault(); 
11270		//         return false;
11271		//     }
11272			
11273		// 	var $el = $(this).parents('.element');
11274		// 	var pid = $el.attr('data-id');
11275		//     $('.blueimp-gallery').addClass('blueimp-gallery-controls');
11276		//     $('.blueimp-gallery a.zoom-in').remove();
11277		// 	$('.blueimp-gallery a.gallery-like').addClass('hide').removeClass('active').removeAttr('data-like');
11278
11279		// 	var gid = $(this).find('a').attr('data-gallery');
11280		//     var totalSlide = $(gid).find('.slide').length;
11281		//     $('.blueimp-gallery .slide-index .total-slide').text(totalSlide);
11282
11283		//     if($(this).find('a').attr('data-img-original') == 'ON') {
11284		// 	    $('.blueimp-gallery a.close').after('<a class="zoom-in" data-id="' + pid + '"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M24 22.94l-6.42-6.42C19.08 14.76 20 12.49 20 10c0-5.52-4.48-10-10-10S0 4.48 0 10s4.48 10 10 10c2.49 0 4.76-0.92 6.52-2.42L22.94 24 24 22.94zM1.5 10c0-4.69 3.81-8.5 8.5-8.5 4.69 0 8.5 3.81 8.5 8.5s-3.81 8.5-8.5 8.5C5.31 18.5 1.5 14.69 1.5 10z"/><polygon points="10.75 6 9.25 6 9.25 9.25 6 9.25 6 10.75 9.25 10.75 9.25 14 10.75 14 10.75 10.75 14 10.75 14 9.25 10.75 9.25 "/></svg></a>');
11285		// 	}
11286			
11287		// 	$(gid).off('slide').off('slideend');
11288		// 	$(gid).on('slide', function (event, index, slide) {
11289		// 		if($(this).find('a').attr('data-gallery-like') != 'N') $('.blueimp-gallery a.gallery-like').removeAttr('data-like').addClass('hide');
11290	    //     }).on('slideend', function(event, index, slide){
11291        // 		$('.blueimp-gallery .slide-index .current-slide').text(index+1);
11292	    //     	if($(this).find('a').attr('data-gallery-like') != 'N') {
11293	    //     		var itemSeq = $el.find('.gallery-item').eq(index).attr('data-seq');
11294		//             if(itemSeq == undefined) {
11295		//                 itemSeq = $('.galleryPL'+pid+'.gallery-popup .gallery-item[data-index='+index+']').attr('data-seq');
11296		//             }
11297		// 			var l_position = setTimeout(function(){
11298		//                 if(!$(slide).hasClass('slide-loading')) {
11299		//                     galleryLikePosition(gid, slide, itemSeq);
11300		//                     clearTimeout(l_position);
11301		//                 }
11302		//             }, 600);
11303	    //     	}
11304	    //     });
11305		// 	$('.blueimp-gallery').find('h3.title').html($(this).find('a').attr('data-title'));
11306
11307		//    	$.cookie('gallery-item', $(this).attr('data-seq'), { path : '/', expires: 12 * 60 * 60 * 1000 });
11308		//    	if(b.PARENT.prev != null) $('.data-page-prev').addClass('active');
11309		//    	if(b.PARENT.next != null) $('.data-page-next').addClass('active');
11310		// 	e.stopPropagation();
11311		// });
11312
11313		// $('body').on('click','.blueimp-gallery a.zoom-in', function(e) {
11314		//     var idx = 0,
11315		//         eid = $(this).attr('data-id');
11316		//     $('#gframe-' + eid + ' .slide').each(function(i,v) {
11317		//         var trans = $(v).attr('style');
11318		//         if(trans.indexOf('translate(0px, 0px)') > -1 || trans.indexOf('transform: translate(0px) translateZ(0px)') > -1) {
11319		//             idx=i;
11320		//         }
11321		//     });
11322		//     // var src = $('#gframe-' + eid + ' .slide[data-index="' + idx + '"] > img').attr('src');
11323
11324		//     // $('.blueimp-gallery a.zoom-in').attr('href',src).attr('target','_blank');
11325		//     e.stopPropagation();
11326		// });
11327``
11328		$('.element[data-type="contact"] .google-map .gm-fullscreen-control').live('click', function(e) {
11329			$(this).toggleClass('gm-open');
11330
11331			if(!$(this).hasClass('gm-open')) {
11332				var el = $(this).closest('.element').attr('data-el');
11333				scrollToBlock('.'+el,300);
11334			}
11335		});
11336
11337		$('#mobile-nav .siteLANG.cl-fixbtn.cl-visible .cl-lang').live({
11338			click: function(e) {
11339				if($('#mobile-nav .siteLANG.cl-fixbtn.cl-visible .dropdown-menu-wrap').hasClass('open')) {
11340					$('#mobile-nav #tpl-menu').css({
11341						'position':'relative',
11342						'z-index':'-1'
11343					});
11344				} else {
11345					$('#mobile-nav #tpl-menu').css({
11346						'position':'',
11347						'z-index':''
11348					});
11349				}
11350			}
11351		});
11352
11353		$('#mobile-nav .dropdown-menu-wrap.open').live({
11354			click: function(e) {
11355				$('#mobile-nav .menu-has-children .dropdown-menu a').css('pointer-events','');
11356				$('#mobile-nav .menu-has-children i.fa-chevron-down').css('z-index','')
11357			}
11358		});
11359	
11360
11361		/* page count */
11362		if(Object.keys(b.CONTENTS).length) {
11363			var ps_elupdate = this.contentUpdate(b.CONTENTS),
11364				vpmode = (typeof $('.mobilepc_ch').attr('data-desktop-option') != 'undefined') ? $('.mobilepc_ch').attr('data-desktop-option') : b.SETTINGS.viewportMode;
11365
11366			ps_elupdate.done(function(r_data) {
11367				elFooter();
11368                if(typeof r_data != 'undefined' && typeof r_data.showOnlyFooter != 'undefined' && r_data.showOnlyFooter) {
11369                	return false;
11370                }
11371				if(b.COUNT) {
11372					if(b.PARENT.mode == 'shopping') {
11373						if(typeof property.PRODINFO === 'object') $.products.display_info();
11374						if($('#review-onoff').val() == 'true') $.products.review(b.VIEW,b.PAGE);
11375						if($('#qna-onoff').val() == 'true') $.products.qna(b.VIEW,b.PAGE);
11376					} else {
11377						if(b.VIEW) _this.displayComment();
11378					}
11379				}
11380			
11381				$('[data-aos-dummy]').each(function() {
11382					$(this).attr('data-aos', $(this).attr('data-aos-dummy')).removeAttr('data-aos-dummy');
11383				});
11384			// }).then(function() {
11385		        // if(typeof b.SETTINGS.viewportMode != 'undefined' && b.SETTINGS.vpMode_onoff===true) {
11386		        // 	console.log(b.SETTINGS.zoom);
11387		        // 	$.mpcWeb.mpcWebhtml(vpmode,b.CONTENTS,b.SETTINGS.zoom);
11388		        // }
11389			}).then(function() {
11390				if(b.VIEW && b.PARENT.mode != 'shopping') {
11391					// initViewPageToolbar().then(function(pageToolbar){
11392	                //     setViewPageToolbar();
11393	                // });
11394					initViewPageBottom();
11395				}
11396	    	}).then(function() {
11397                if(typeof b.SETTINGS.hideScrollTop != 'undefined' && b.SETTINGS.hideScrollTop == true)  $('#goto-top').addClass('hide');
11398				if(b.VALIDPLAN && b.VALIDTYPE != 'PK') {
11399					var ismodeSm = ($('.cl-s-page').hasClass('mode-shopping')) ? true : false;
11400					if(!ismodeSm && b.ONE && !b.VIEW || b.PAGE == b.MENULINK[0] && !b.VIEW)	setSitePopup();
11401					$.siteBanner.init(true,true);
11402
11403					if(b.VALIDTYPE == 'BN' || b.VALIDTYPE == 'SM') {
11404						if(typeof b.SETTINGS.fnav != 'undefined' && !$.isEmptyObject(b.SETTINGS.fnav) && (typeof b.SETTINGS.qm_onoff == 'undefined')) {
11405							$.fnav.draw(b.SETTINGS.fnav);
11406						}
11407					
11408						if(typeof b.SETTINGS.qm_onoff != 'undefined' && b.SETTINGS.qm_onoff==true) {	
11409							var quick_type = ($('body').width() > 768) ? 'pc' : 'mobile';
11410						
11411							if(!(b.PARENT.page != null && (quick_type=='mobile'))) {
11412								if($('.menu-lock-block').length>0) return false;
11413								if(!(ismodeSm && (quick_type=='mobile'))) {
11414									$.quickmenu.init(b.SID, b.PUBLISH,quick_type);
11415									mobileWebQuickmenuPosition(b,quick_type);
11416								}
11417								
11418							}			
11419						}
11420
11421					}
11422				}
11423
11424				if(typeof b.SETTINGS.viewportMode != 'undefined' && b.SETTINGS.vpMode_onoff===true) {
11425					mobileWebfnavCheck(vpmode);
11426				}
11427
11428				if($('#page-loading-css').length > 0) {
11429					if($('header.navbar').hasClass('navbar-fheader')) $.fheader.position();
11430					$('#page-loading-css').remove(); 
11431				}
11432	    	});
11433		} 
11434		else {
11435			var checkUrl = b.PAGE.split(","),
11436				vpmode = '';
11437				vpmode = $.mpcWeb.mpcGetVpmode(vpmode,b.SETTINGS);
11438
11439			isMenuLock(function() {
11440				if(b.SETTINGS.noError404 === true && !(b.MENULIST.indexOf(b.PAGE) > -1) && !b.ONE && !b.VIEW) { // refresh
11441					window.location.href = '/';
11442					return false;
11443				}
11444				
11445				if($('#page-loading-css').length > 0) {
11446					if($('header.navbar').hasClass('navbar-fheader')) $.fheader.position();
11447					$('#page-loading-css').remove(); 
11448				}
11449
11450				if(property.ISLOCK == 'false') {
11451					if(property.COUNT==0) {
11452						elFooter();
11453						if(checkUrl[0] == "forum" && b.VIEW) {				
11454							if(b.VALIDPLAN && b.VALIDTYPE != 'PK' && typeof b.SETTINGS.viewportMode != 'undefined' && b.SETTINGS.vpMode_onoff===true) {
11455								$.mpcWeb.mpcWebhtml(vpmode,b.CONTENTS,b.SETTINGS.zoom);
11456							}
11457							var ps_fmview = $.forum.view(b.VIEW);
11458							ps_fmview.done(function(data) {
11459								if($(`.page-comments[data-id="${b.VIEW}"]`).length == 0) _this.displayComment(data);
11460
11461								setTimeout(function() {
11462									if(b.VIEW) setViewPageToolbar();
11463									if(b.VALIDPLAN && (b.VALIDTYPE == 'BN' || b.VALIDTYPE == 'SM')) {
11464										if(typeof b.SETTINGS.fnav != 'undefined' && !$.isEmptyObject(b.SETTINGS.fnav) && (typeof b.SETTINGS.qm_onoff == 'undefined')) $.fnav.draw(b.SETTINGS.fnav);
11465									}
11466									if(b.VALIDPLAN && b.VALIDTYPE != 'PK' && typeof b.SETTINGS.viewportMode != 'undefined' && b.SETTINGS.vpMode_onoff===true) {
11467										$.mpcWeb.mpcWebhtml(vpmode,'',b.SETTINGS.zoom);
11468										mobileWebfnavCheck(vpmode);
11469									}
11470								}, 100);
11471
11472							}).fail(function(error_msg) {
11473								// console.log(error_msg);
11474							});
11475						}
11476
11477						if(property.PAGE == 'psearch') {
11478							vpmode = $.mpcWeb.mpcGetVpmode(vpmode,property.SETTINGS);
11479
11480							if(b.VALIDPLAN && b.VALIDTYPE != 'PK' && typeof property.SETTINGS.viewportMode != 'undefined' && property.SETTINGS.vpMode_onoff===true) $.mpcWeb.mpcWebhtml(vpmode,property.CONTENTS,property.SETTINGS.zoom);
11481
11482							setTimeout(function() {
11483								if(property.VALIDPLAN && (property.VALIDTYPE == 'BN' || property.VALIDTYPE == 'SM')) {
11484									if(typeof property.SETTINGS.fnav != 'undefined' && !$.isEmptyObject(property.SETTINGS.fnav) && (typeof b.SETTINGS.qm_onoff == 'undefined')) $.fnav.draw(property.SETTINGS.fnav);
11485								}
11486								if(typeof property.SETTINGS.viewportMode != 'undefined' && property.SETTINGS.vpMode_onoff===true) {
11487									mobileWebfnavCheck(vpmode);
11488								}
11489							}, 500);
11490						}
11491
11492						var ismodeSm = ($('.cl-s-page').hasClass('mode-shopping')) ? true : false;
11493						if(b.VALIDPLAN && b.VALIDTYPE != 'PK') {
11494							if(!ismodeSm && b.ONE && !b.VIEW || b.PAGE == b.MENULINK[0] && !b.VIEW) setSitePopup(); 
11495							$.siteBanner.init(true,true);
11496						}
11497						if(b.VALIDPLAN && (b.VALIDTYPE == 'BN' || b.VALIDTYPE == 'SM')) {
11498							if(typeof b.SETTINGS.fnav != 'undefined' && !$.isEmptyObject(b.SETTINGS.fnav) && (typeof b.SETTINGS.qm_onoff == 'undefined')) {
11499								$.fnav.draw(b.SETTINGS.fnav);
11500							}
11501
11502							if(typeof b.SETTINGS.qm_onoff != 'undefined' && b.SETTINGS.qm_onoff==true) {
11503								var quick_type = ($('body').width() > 768) ? 'pc' : 'mobile';
11504								if(!(b.PARENT.page != null && (quick_type=='mobile'))) $.quickmenu.init(b.SID, b.PUBLISH,quick_type);
11505							}
11506						}
11507
11508						if(b.VALIDPLAN && b.VALIDTYPE != 'PK' && typeof b.SETTINGS.viewportMode != 'undefined' && b.SETTINGS.vpMode_onoff===true) {
11509							$.mpcWeb.mpcWebhtml(vpmode,'',b.SETTINGS.zoom);
11510							mobileWebfnavCheck(vpmode);
11511						}
11512
11513					}
11514				} else {
11515					elFooter();
11516				}
11517			});
11518		}
11519
11520		window._musicUserInteracted = false;
11521		$(document).one('click scroll touchstart keydown', function() {
11522			window._musicUserInteracted = true;
11523		});
11524
11525	    $(window).load(function() {
11526
11527	    	$('#no-fouc').css('opacity','1');
11528	        if(typeof $.cookie('gallery-return-page') != 'undefined' && b.VIEW == '') {
11529	            restoreGalleryReturnTarget();
11530	        } else if(typeof $.cookie('gallery-item') != 'undefined' && b.VIEW == '') {
11531	        	moveGallery($.cookie('gallery-item'));
11532	        }
11533	        
11534	        if(typeof $.cookie('forum_content_view') == 'undefined'){
11535		        moveScroll(0);
11536		    }
11537		    _this.loaded();
11538
11539            if(b.VALIDPLAN && b.VALIDTYPE != 'PK') {
11540			    var musicPlay = true;
11541			    if(typeof b.SETTINGS.musicStop != 'undefined' && (b.SETTINGS.musicStop === true || b.SETTINGS.musicStop == 'true'))
11542			    	musicPlay = false;
11543
11544			    if(typeof b.SETTINGS.musicUse != 'undefined' && (b.SETTINGS.musicUse === true || b.SETTINGS.musicUse == 'true')){
11545 					if( (typeof b.SITELOCK != 'undefined' && b.SITELOCK == 'true' ) || b.certOpenChk == true) {
11546						musicPlay = false;
11547					} else {
11548						$.musicON(musicPlay);
11549					}				
11550				}
11551
11552				// JH 주석1 : 위 내용 주석 후 아래 주석 풀기
11553				// if(typeof b.SETTINGS.musicUse != 'undefined' && (b.SETTINGS.musicUse === true || b.SETTINGS.musicUse == 'true'))
11554				// $.musicON(musicPlay);
11555					
11556				if(musicPlay == false) $.musicPause();
11557			}
11558
11559			var used_disk_value = b.USED_DISK / 1024,
11560				used_disk = Math.ceil(used_disk_value); // byte으로 가져와서 megsabyte으로 변한다
11561
11562			if(Number(b.DISK_SPACE) != -1 && (used_disk > b.DISK_SPACE) && (b.MB_LEVEL != 10)) setlimitdiskPopup();
11563
11564			// menu sidebar - height overflow
11565			if($('body').width() > 768) {
11566				$('header.navbar-li:not([data-fixtype]) #fixed-menu > li.dropdown').live({
11567					mouseenter: function(e) {
11568						var this_bottom = $(this).find('.cl-icon').position().top + $(this).find('.cl-icon').height();
11569						$(this).find('.dropdown-menu').css({
11570							'top': this_bottom+'px',
11571						});
11572					},
11573					mouseleave: function(e) {
11574						$(this).find('.dropdown-menu').removeAttr('style');
11575					}
11576				});
11577
11578				$('header.navbar-li[data-fixtype] #fixed-menu > li.dropdown').live({
11579					mouseenter: function(e) {
11580						var dropdown_cover = '<div class="dropdown_cover"></div>',
11581							this_bottom = 0,
11582			                is_fhAlign = (typeof $('.el-menu header.navbar[data-fixtype]').find('.container').attr('data-fh-align') != 'undefined') ? true : false,                         
11583			                checkSidebar = ($('.el-menu header.navbar').hasClass('sidebar')) ? true : false,
11584			                $cl_fixbtn = ($('header.navbar[data-fixtype] .cl-fixed-menu .cl-fixbtn.cl-visible').length>0) ? $('header.navbar[data-fixtype] .cl-fixed-menu .cl-fixbtn.cl-visible') : '',
11585			                visible_aHght = ($(this).find(' > a:visible').length>0) ? $(this).parents('.cl-fixed-menu').find('li.cl-fixbtn').height() : 10;
11586			                	
11587						var height_arr = [],
11588			        		height_max = '';
11589
11590		        		$cl_fixbtn.find('> a:visible').each(function(){
11591		        			var fixbtn_height = ($(this).find('.cl-icon').length>0) ? $(this).find('.cl-icon').height() : $(this).height(),
11592		        				fixbtn_fsize = Number($(this).css('font-size').replace(/px/gi,''));
11593
11594								// console.log($(this).height());
11595								// console.log($(this).parents('li.cl-fixbtn').height());
11596	        				if($(this).height() != $(this).parents('li.cl-fixbtn').height()) {
11597	        					fixbtn_height = ($(this).find('.cl-icon').height() > $(this).height()) ? $(this).find('.cl-icon').height() : 
11598		        				(($(this).find('.cl-icon').height() + fixbtn_fsize < $(this).height()) ? fixbtn_fsize : $(this).outerHeight());
11599	        				} 
11600		        		
11601        					height_arr.push(fixbtn_height);
11602		        		});
11603
11604		        		height_max = Math.max(...height_arr);
11605				
11606						var li_Hght = 0;
11607						$(this).parents('.cl-fixed-menu').find('li.cl-fixbtn').each(function(i,v){
11608							var li_display = $(this).css('display');
11609							if(li_display!='none') {
11610								li_Hght = Number($(this).height());
11611								return false;
11612							}
11613						});
11614
11615		        		var li_Hght_half = Number((li_Hght/2).toFixed(0)),
11616		        			height_max_half = Number((height_max/2).toFixed(0)),
11617		        			ul_height_max_cal = li_Hght_half - height_max_half;
11618		        		
11619		        		ul_height_max_cal = (ul_height_max_cal <= 0 && ul_height_max_cal>-3) ? 0 : ul_height_max_cal;
11620	        			this_bottom = ul_height_max_cal + Number(height_max.toFixed(0)) + 5;
11621
11622		             	//if(!is_fhAlign && !checkSidebar && $(this).hasClass('siteLANG')) { this_bottom -= ul_height_max_cal;}
11623
11624						if(checkSidebar) {
11625							var fixtype = $('.el-menu header.navbar').attr('data-fixtype'),
11626								fixtype_check_arr = ['01','02','03','08'];
11627							this_bottom = ($.inArray(fixtype,fixtype_check_arr)>-1) ? this_bottom : visible_aHght;
11628						} 
11629						
11630						if(!checkSidebar) {
11631			                $(this).find('.dropdown-menu').before(dropdown_cover);
11632			            }
11633					
11634			            $(this).find('.dropdown-menu').css({
11635							'top': this_bottom+'px'
11636						});
11637
11638
11639					},
11640					mouseleave: function(e) {
11641						$(this).find('.dropdown-menu').removeAttr('style');
11642            			$(this).find('.dropdown_cover').remove();
11643					}
11644				});
11645
11646				$('.sidebar .nav li.dropdown').live({
11647					mouseenter: function(e) {
11648						var checkSubMenuPosition = $(this).find('.dropdown-menu').css('position');
11649						if(checkSubMenuPosition == 'absolute') {
11650							var this_top = $(this).offset().top - $(document).scrollTop();
11651							if($(this).closest('header').parent('#element-display').length > 0) this_top -= $(this).closest('header').parent('#element-display').offset().top;
11652							
11653							$(this).find('.dropdown-menu').css({
11654								'position': 'fixed',
11655								'top': this_top+'px',
11656								'left': '260px'
11657							});
11658						}
11659					},
11660					mouseleave: function(e) {
11661						$(this).find('.dropdown-menu').removeAttr('style');
11662					}
11663				});
11664			} else {
11665				$('header.navbar-li #fixed-menu > li.dropdown').find('.dropdown-menu').removeAttr('style');
11666				$('header.sidebar #tpl-menu > li.dropdown').find('.dropdown-menu').removeAttr('style');
11667			}
11668
11669
11670			if(typeof $.cookie('ci_goto-gallery') != 'undefined' && $.cookie('ci_goto-gallery')) {
11671				var goto_gallery = '.element[data-id="' + $.cookie('ci_goto-gallery') + '"]',
11672					cookie_domain =  (property.HOST.indexOf(':') > -1) ? property.HOST.substring(0,property.HOST.indexOf(':')) : property.HOST;
11673				if($(goto_gallery).length > 0) {
11674					scrollToBlock(goto_gallery, 1000);
11675				}
11676				$.cookie('ci_goto-gallery', '', { domain: '.' + cookie_domain,expires: -1 });
11677				$.cookie('ci_goto-gallery-cate', '', { domain: '.' + cookie_domain,expires: -1 });
11678			}
11679
11680			if(isAosBlock) {
11681				$('body,html').addClass('aos-height aos-overflowX');
11682				if($('header.navbar').hasClass('navbar-fheader')) $.fheader.position();
11683			} else {
11684				$('body,html').removeClass('aos-height aos-overflowX');
11685			}
11686
11687			if(typeof fbq == 'function' && b.VALIDTYPE == 'SM') {
11688				if(b.VIEW) {
11689					var checkProduct = (b.PAGE.match(/^forum,/g) === null && typeof b.PARENT != 'undefined' && typeof b.PARENT.mode != 'undefined' && b.PARENT.mode == 'shopping') ? true : false,
11690						mn = (b.ONE) ? b.PARENT.opage : b.PARENT.ppage;
11691					if(checkProduct && typeof callbackEvtViewContent == 'function') callbackEvtViewContent(mn,b.PARENT.seq,b.PARENT.title,$('.total-price').text().replace(/[^0-9]/g,''));
11692				} else {
11693					var checkProductList = ($('.element[data-type="gallery"][data-mode="shopping"]').length > 0) ? true : false;
11694					if(checkProductList && typeof callbackEvtLead == 'function') callbackEvtLead(b.PAGE);
11695				}
11696			}
11697
11698			if(refreshInitialTabmenuPage) {
11699				if(initialTabmenuPageChanged) {
11700					var tabmenuEntryUrl = (b.PUBLISH ? '' : '/render') + '/' + b.PAGE;
11701					window.history.replaceState(null, b.TITLE, tabmenuEntryUrl);
11702				}
11703				clearDsgnbody();
11704				elPush(true);
11705			}
11706
11707	    });
11708    },
11709    contentUpdate : function(contents) {
11710    	// console.log(' page draw 01:: contentUpdate');
11711	    var deferred = $.Deferred();
11712    	var b = this.b,
11713    		_this = this,
11714    		idx = 0;
11715    	
11716    	var checkSiteLock = isSitePasswordLock();
11717		checkSiteLock.then(function() {
11718			isMenuLock(function() {
11719				var default_t_css = '', default_m_css  = '';
11720				var checkGalleryView = (b.VIEW && b.PAGE.match(/^forum,/g) === null) ? true : false,
11721					page_pos = 0,
11722					site_settings = (typeof b.SETTINGS != 'undefined' && b.SETTINGS) ? b.SETTINGS : {},
11723					vpmode = '';
11724                var is_templates = checkTemplateSite(b.SID);
11725				vpmode = $.mpcWeb.mpcGetVpmode(vpmode,b.SETTINGS);
11726				if(b.VALIDPLAN && b.VALIDTYPE != 'PK' && typeof b.SETTINGS.viewportMode != 'undefined' && b.SETTINGS.vpMode_onoff===true) {
11727					$.mpcWeb.mpcWebhtml(vpmode,b.CONTENTS,b.SETTINGS.zoom);
11728				}
11729
11730				if(checkGalleryView) setViewPageStyle();
11731
11732				var check_modoo = $('.dsgn-body').hasClass('modoo') ? true : false,
11733					fl_data = {};
11734					
11735				if(check_modoo || property?.SETTINGS?.modoo?.floating ) { 
11736					fl_data = draw_floating();
11737				}
11738
11739				$.each(contents, function(i,v) {
11740		    		page_pos += 1;
11741					// console.log(`i: ${i}, v: `);console.log(v);
11742		    		var c = v.element;
11743		    		var $el = $('.' + c.elname);
11744					if(c.tabmenu_section_page) $el.attr('data-tabmenu-page', c.tabmenu_section_page);
11745					var settings = (c.elsettings == '' || typeof c.elsettings == 'undefined') ? {} : $.parseJSON(c.elsettings);
11746					var block_lang = (typeof settings.blocklang != 'undefined') ? settings.blocklang : LANG;
11747		    		var msny = (c.feature=='masonry') ? true : false;
11748
11749					if(c.type == 'video') {
11750						c.mode = ($el.find('.video-gallery-url').length > 0) ? 'zoom' : 'thumb';
11751					}
11752
11753		            //처음 접속 시
11754		            $el.addClass('el_' + idx)
11755		            	.addClass('element')
11756		                .attr('data-id', c.seq)
11757		                .attr('data-el','el_' + idx)
11758		                .attr('data-pos', c.pos)
11759		                .attr('data-name', c.elname)
11760		                .attr('data-msny', msny)
11761		                .attr('data-type', c.type)
11762		                .attr('data-type2', c.type2)
11763						.attr('data-feature', c.feature)
11764		                .attr('data-mode', c.mode)
11765		                .attr('data-width', c.folder)
11766		                .attr('data-overlap',c.overlap)
11767		                .attr('data-case', settings?.blockorg || c.name);
11768					if(c.type == 'form' && typeof c.form_done != 'undefined') $el.attr('data-form-done', c.form_done);
11769
11770					setBlockAOS($el,{block:settings, skipRefresh:true});
11771
11772					if($el.hasClass('modoo')) {
11773						if(window.innerWidth <= 768 && $el.find('._spotHomesite').hasClass('is_bottom')) {
11774							$el.find('._spotHomesite').removeClass('is_bottom');
11775						}
11776
11777						if($el.find('._sectionSpot').hasClass('type_full') && window.innerWidth > 768) {
11778							var A = $el.find('._areaLogin').length ? true : false,
11779								C = window.innerHeight;
11780		
11781							if (A) {
11782								C -= 50;
11783							}
11784							
11785							$el.find("._sectionSpot .swiper-wrapper").css("height", C);
11786							$el.find("._sectionSpot .swiper-slide").css("height", C);
11787							$el.find("._sectionSpot ._imgCover").css("height", C).each(function(F, G) {
11788								var D = $(G);
11789								var E = D.attr("data-lazy-background-img-src");
11790								D.css({
11791									backgroundImage: "url(" + E + ")",
11792									filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + E + '}", sizingMethod="scale")'
11793								});
11794							});
11795							if (!$el.find("._spotHomesite").hasClass("is_bottom")) {
11796								$el.find("._spotHomesite").css("height", C);
11797							}
11798						}
11799						if($el.find('.page-container-mobile').length > 0) {
11800							if(window.innerWidth <= 768) $el.find('[data-role="page-container"]._content').hide();
11801							else $el.find('[data-role="page-container"]._content').show();
11802						}
11803
11804						if($el.parents('body').is('.clnav-overlap-OFF') && $el.is('[data-el="el_0"]')) {
11805							$el.find('._spotHomesite .site_info').append(fl_data.el_html);
11806						}
11807					}
11808
11809					if(c.type == 'contact') {
11810						setContactSubmitSecurity($el, c.seq, settings, block_lang);
11811					}
11812
11813
11814					var tabmenuSectionStart = c.tabmenu_section_start || '';
11815					var checkPageblock = (c.seq === 'all_products' || (c.orgpos == 1 && c.orgpage)) ? true : false;
11816					if(tabmenuSectionStart) {
11817						$el.attr('data-pagename', JSON.parse('"' + tabmenuSectionStart + '"'));
11818						$el.addClass('link-to-'+JSON.parse('"'+tabmenuSectionStart.replace(/ /g,'-')+'"'));
11819					}
11820					if(b.ONE && checkPageblock) {
11821						$el.attr('data-pagename', JSON.parse('"' + c.orgpage + '"'));
11822						$el.addClass('link-to-'+JSON.parse('"'+c.orgpage.replace(/ /g,'-')+'"'));
11823					}
11824
11825					var checkNotSupported = (!is_templates) ? $.notSupported.check(v.element.type,v.element.type2,v.element.feature) : false;
11826					if(checkNotSupported) {
11827						$(`.${v.element.elname}`).html('').attr('class',`hide element ${v.element.elname} el_${idx}`);
11828						$(`#el_${idx}css, #js_${idx}`).remove();
11829						idx++;
11830						return;
11831					}
11832
11833					$el.find('video').attr({'playsinline': '','webkit-playsinline': ''});
11834					if(c.type == 'video' || c.type == 'others') {
11835						var checkFullscreen = (typeof settings.fullscreen != 'undefined' && settings.fullscreen == 'ON') ? true : false;
11836						if(checkFullscreen) $el.find('.video-wrap').addClass('video-fullscreen');
11837					}
11838
11839		            if($el.length > 1 && c.type == 'showcase') {
11840			            $($el).each(function(i, v) {
11841			           		if(i>0) v.dataset['el'] = '';
11842			            });
11843		            }
11844					
11845					if($el.hasClass('error_404')==false) {
11846						if($el.hasClass('el-footer')==false) {
11847							if($el.hasClass('cl-s-product-detail')==false) {
11848								if(typeof setBlockAOS == 'function') setBlockAOS($el,{block:settings, skipRefresh:true});
11849								else aosAddblock(site_settings,settings,$el);
11850							}						
11851						}
11852					}
11853
11854					var data_aos_attr = '';
11855					if($el.is('[data-aos]')) {
11856						data_aos_attr = $el.attr('data-aos');
11857						$el.removeAttr('data-aos');
11858						$el.addClass('aos-init')
11859					}
11860
11861	              	var blocklang = '';
11862					if(typeof settings.blocklang != 'undefined') {
11863		                blocklang = settings.blocklang;
11864		                $el.attr('data-blocklang',blocklang);
11865		            }
11866
11867					if (c.type == 'sync') {
11868						showHideSyncField($el, settings);
11869	
11870						var sync_list_total = (typeof v.element.sync !='undefined' && typeof v.element.sync.list != 'undefined' && (v.element.sync.list).length > 0) ? (v.element.sync.list).length : 0;
11871						if($el.find('.slick-page-label').length > 0) {
11872							var page_label = sync_list_total;
11873							if(c.type2 == 'imgpitem' && sync_list_total == 0) page_label = $el.find('.slick .item').length;
11874
11875							$el.find('.slick-page-label .slick-page-now').text(1);
11876							$el.find('.slick-page-label .slick-page-total').text(page_label);
11877						}
11878
11879						if($el.find('.sync-option').length > 0) {
11880							var sync_css = CSSJSON.toJSON(htmlspecialchars_decode(c.elcss)),
11881								sync_s = style.get(sync_css,c.elname);
11882							if(typeof sync_s.__display_count != 'undefined') {
11883								var display_cnt = Number(sync_s.__display_count) || 10;
11884								$el.find(`.sync-item:gt(${display_cnt-1})`).addClass('hide');
11885
11886								if($el.find('.sync-page-label').length > 0) {
11887									var sync_p_cnt = $el.find('.sync-row .sync-item').length,
11888										sync_p_total = Math.ceil(sync_p_cnt / display_cnt);
11889									$el.find('.sync-page .sync-page-now').text(1);
11890									$el.find('.sync-page .sync-page-total').text(sync_p_total);
11891									
11892									if(sync_p_total == 1) $el.find('.sync-page-wrap').hide();
11893									else $el.find('.sync-page-wrap').show();
11894								}
11895							}
11896						}
11897
11898						var sync_loadmore_lang = block_lang;
11899						if(typeof settings.loadmore_lang != 'undefined' && settings.loadmore_lang && $.inArray(settings.loadmore_lang.toLowerCase(), ['ko','en']) > -1) sync_loadmore_lang = settings.loadmore_lang.toLowerCase();
11900						$el.find('.sync-page-more-str').text($.lang[sync_loadmore_lang]['config.loadmore']);
11901					}
11902
11903					if(checkGalleryView) {
11904						if(c.page == 'fixedblock_'+b.PARENT.pid) $el.addClass('el-fixedblock');
11905						else $el.removeClass('el-fixedblock');
11906
11907						$el.attr('data-pos', page_pos);
11908						// if(b.LUX && (c.orgpos == '1' || $el.is('.lux-product-block'))) $el.attr('data-ppos', (c.pos*1) + 1);
11909						// else $el.attr('data-ppos', c.pos);
11910						$el.attr('data-ppos', c.pos);
11911						$el.attr('data-posby', c.elnew);
11912					}
11913
11914					if(c.type == 'contact' && c.page == 'fixedcontact') {
11915						$.fixedContact.init($el);
11916		            }
11917
11918		            // b.ISLOCK = (!b.VALIDPLAN) ? 'false' : b.ISLOCK;
11919		            if(b.ISLOCK == 'false') $el.removeClass('hide');
11920		            else $el.addClass('locked');
11921
11922		            if(c.type == 'forum' || c.type == 'latest' || c.type == 'sync') $el.addClass('preloading');
11923
11924					var elFonts = $el.css('font-family');
11925					elFonts = elFonts + ",'Nanum Gothic'";
11926					var reFonts = elFonts.replace(/"/g, "\'");
11927					$el.css('font-family',reFonts);
11928
11929		            //add style
11930		            var jcss = CSSJSON.toJSON(c.elcss);
11931
11932					var element_mh = jcss?.children[`.${c.elname}`]?.attributes['min-height'] ?? '';
11933					if (element_mh && /%$/.test(element_mh)) {
11934						const converted_mh = element_mh.replace('%', '');
11935						$el.css('min-height',`${converted_mh}vh`);
11936					}
11937
11938		            var elpd = style.getPadding(jcss,c.elname);
11939		            var pt = parseInt(elpd.top);
11940		            var pb = parseInt(elpd.bottom);
11941		                
11942		            if(pt>0||pb>0){
11943		                default_t_css = default_t_css + '\n 	.'+c.elname + '{';
11944		                if(Math.ceil(pt*0.8)>0)
11945		                default_t_css = default_t_css + 'padding-top: '+Math.ceil(pt*0.8) + 'px!important;';
11946		                if(Math.ceil(pb*0.8)>0)
11947		                default_t_css = default_t_css + 'padding-bottom: '+Math.ceil(pb*0.8) + 'px!important;';
11948		                default_t_css = default_t_css + '}';
11949
11950		                default_m_css = default_m_css + '\n 	.'+c.elname + '{';
11951		                if(Math.ceil(pt*0.5)>0)
11952		                default_m_css = default_m_css + 'padding-top: '+Math.ceil(pt*0.5) + 'px!important;';
11953		                if(Math.ceil(pb*0.5)>0)
11954		                default_m_css = default_m_css + 'padding-bottom: '+Math.ceil(pb*0.5) + 'px!important;';
11955		                default_m_css = default_m_css + '}';
11956		            }
11957		            
11958		            if(idx == Object.keys(b.CONTENTS).length-1){
11959		                var css = '@media only screen and (max-width:767px) {' + default_t_css + '\n}\n';
11960		               	css = css + '@media only screen and (max-width:480px) {' + default_m_css + '\n}';
11961
11962		                if($('#el-paddingcss').length == 0) $('.dsgn-body').find('#el_'+(Object.keys(b.CONTENTS).length-1)+'css').after('<style id="el-paddingcss">'+css+'</style>');
11963		                else $('#el-paddingcss').append(css);
11964		            }
11965
11966		            var settings = (c.elsettings == '' || typeof c.elsettings == 'undefined') ? {} : $.parseJSON(c.elsettings);
11967
11968					if(typeof settings.bookmark != 'undefined' && settings.bookmark) {
11969						$el.attr('data-bookmark',c.seq);
11970					}
11971					
11972					if(b.VIEW && (c.type == 'project' || c.type == 'product')) {
11973						$el.find('.data-page-prev').addClass('active');
11974						$el.find('.data-page-next').addClass('active');
11975
11976	                    if(b.PARENT.prev == null) $el.find('.data-page-prev').removeClass('active');
11977	                    if(b.PARENT.next == null) $el.find('.data-page-next').removeClass('active');
11978
11979	                    //상세페이지 배경 style 추가
11980	                    // if(c.type == 'project') setGalleryProjectCss(b.PARENT,b.PARENT['elcss']);	                	
11981	                }
11982
11983	                if(b.VIEW) {
11984		            	var img_onoff = (typeof settings.img_original_display != 'undefined' && settings.img_original_display) ? settings.img_original_display : 'OFF';
11985		            	$el.find('img[data-attach="true"]').attr('data-img-original',img_onoff);
11986	                }
11987
11988					//video block ::: gallery
11989			        if(c.type == 'video') {
11990			            if($el.find('.video-gallery-url').length > 0) { //재생방식 : 확대보기 
11991			                $.each($el.find('.item'),function(i,v){
11992			                    if(c.mode=='zoom') appendGalleryFrame($(this).parents('.element'),c.seq,c.type);
11993			                });
11994
11995		                    // let lsw = document.querySelector('.element[data-id="' + c.seq + '"] .swiper');
11996		                    // if(lsw && lsw.swiper) {
11997		                    //     let slider_motion = $('.element[data-id="' + c.seq + '"]').attr('data-sli
11997der-motion');
11998
11999		                    // 	$('#gframe-' + c.seq).on('opened', function(event){
12000					        //     	console.log('gallery opend', $(this).data('gallery'), typeof $(this).data('gallery').index);
12001		                    //         if(slider_motion != 'stop') {
12002		                    //             lsw.swiper.autoplay.stop();
12003		                    //         }
12004			                //     }).on('closed', function (event){
12005					        //     	console.log('gallery closed');
12006		                    //         if(slider_motion != 'stop') {
12007		                    //             lsw.swiper.autoplay.start();
12008		                    //         }
12009			                //     });
12010		                    // }
12011			            }			            
12012
12013						resizeVideoIframe($el);
12014			        }
12015
12016					if(c.type == 'forum') {
12017						var page_num = 1
12018						if (typeof $.cookie('forum_' + v.element.seq) != 'undefined' && $.cookie('forum_' + v.element.seq)) {
12019							page_num = $.cookie('forum_' + v.element.seq);
12020						} 
12021						_this.forumUpdate(v.element.seq, page_num, v.view, c.page, v.list);
12022					} else if(c.type == 'gallery') {
12023	                    _this.galleryEL[c.seq] = {
12024	                    	'seq' : c.seq,
12025	                    	'elname' : c.elname,
12026	                    	'eltag' : c.eltag,
12027	                    	'folder' : c.folder,
12028	                    	'mode' : c.mode,
12029	                    	'elsettings' : c.elsettings,
12030	                    	'feature' : c.feature,
12031	                    	'type' : c.type,
12032	                    	'type2' : c.type2,
12033							'searches' : c.searches
12034	                    };
12035
12036						_this.galleryUpdate(c,v);
12037                        if(c.only_category) {
12038                            localStorage.setItem('searches',JSON.stringify(new Array(c.searches.uri[0])));
12039                        }
12040
12041						if (isShoppingGradePriceHidden(c)) {
12042							$el.find('.figure.price').html('');
12043						}
12044
12045						//갤러리블럭 모바일 가로 갯수 설정 시 클래스추가
12046						var gal_css = CSSJSON.toJSON(htmlspecialchars_decode(c.elcss)),
12047							gal_s = style.get(gal_css,c.elname),
12048							gal_case = $el.attr('data-case');
12049						if(gal_s.__layout_m_on == 1 && gal_case != 'gallery61') {
12050							$el.addClass('el-col-m'+gal_s.__layout_col_mc);
12051						} else if(gal_s.__layout_m_on == 1 && gal_case == 'gallery61') {
12052							$el.addClass('el-col-m'+gal_s.__swiper_view_mc);
12053						}
12054					} else if(c.type == 'sync') {
12055						var sync_source = _this.syncUpdate($el,v.element);
12056						$el.html(sync_source);
12057
12058						if($el.find('[data-sync-loop="true"]').length > 0) {
12059							if(c.type2 == 'tab') $el.find('[data-sync-loop="true"] > li[data-list-no="1"]').attr('data-list-no','');
12060							if(c.type2 == 'imgpitem' && sync_list_total > 0) $el.find('[data-sync-loop="true"] > li:not([data-idx])').remove();
12061							$el.find('[data-sync-loop="true"] > li').eq(0).addClass('active').siblings().removeClass('active');
12062						}
12063						
12064					} else if(c.type == 'tabs') {
12065						// tab block 우선순위 check
12066						var $tabs = $el.find(".tab-box .tab:not(.hover)"),
12067							$initial_tab = ($tabs.filter('.checked').length > 0) ? $tabs.filter('.checked').first() : $tabs.filter('.active').first();
12068						if($initial_tab.length == 0) $initial_tab = $tabs.eq(0);
12069						if($tabs.filter('.checked').length > 0) {
12070							$tabs.removeClass('active');
12071							$initial_tab.addClass('active');
12072							$el.find('.tab-editor').removeClass('active');
12073							$el.find('.tab-editor.tabs' + $initial_tab.attr('data-order')).addClass('active');
12074						}
12075						var el = $el.attr('data-name'),
12076							len = $tabs.length,
12077							motion_style = $el.attr("tab-motion-style"),
12078							tab_counted = $el.attr("tab-count"),
12079							mobile_tab_count = $el.attr("mobile-tab-count"),
12080							tab_count = ($(window).width() < 991) ? ((typeof mobile_tab_count != 'undefined' && mobile_tab_count) ? mobile_tab_count : ((tab_counted > 4) ? 4 : tab_counted)) : tab_counted,
12081							mobile_tab_line = $el.attr("mobile-tab-line"),
12082							tab_case = $el.attr("data-case"),
12083							motion = $el.attr("tab-motion"),
12084							priority = Number($initial_tab.attr('data-order')) || 1,
12085							navigation_use = $el.attr("navigation-use");
12086						tabArrow(el);
12087						if(navigation_use == '1' || ($(window).width() < 991 && mobile_tab_line == '1' && len > Number(tab_count))) {
12088							if(motion_style == 1) {
12089								var motion = (((priority + 1) - Number(tab_count)) >= 0) ? priority - Number(tab_count) : 0;
12090							} else {
12091								var motion = Math.ceil(Number(priority) / Number(tab_count)) - 1;
12092							}
12093							$el.attr('tab-motion', motion);
12094							tabMotion(el, motion, "", len, motion_style, tab_count, tab_case);
12095						}
12096
12097					} else if(c.type == 'sns' && c.type2 == 'feed') {
12098		                $el.find('.data-feed-load-more').attr('data-feed-el',c.elname);
12099		                $el.find('.data-feed-load-more').removeAttr('style');
12100		                $el.find('.show-posts').removeClass('show-posts');
12101
12102		                if(c.mode == 'site') {
12103							if(!$.isEmptyObject(b.SOCIAL)) {
12104								var load_sns = {};
12105								if(!$.isEmptyObject(b.SOCIAL.instagram) && typeof settings.sns_instagram != 'undefined' && settings.sns_instagram == 'ON') load_sns['instagram'] = b.SOCIAL.instagram;
12106								if(!$.isEmptyObject(b.SOCIAL.twitter) && typeof settings.sns_twitter != 'undefined' && settings.sns_twitter == 'ON') load_sns['twitter'] = b.SOCIAL.twitter;
12107
12108								if(!$.isEmptyObject(load_sns)) {
12109									loadingElement(c.elname,'loading posts...');
12110									updateFeed(c.elname, load_sns, settings, function() {
12111										$('.'+c.elname+' .listprogress').remove();
12112									});
12113								}
12114							}
12115		                } else {
12116							// SNS FEED:: before version
12117							if(typeof settings.sns != 'undefined' && settings.sns.twitter) {
12118								loadingElement(c.elname,'loading posts...');
12119								updateFeed(c.elname,settings.sns);
12120							}
12121		                }
12122
12123					} else if(c.type == 'others' && c.type2 == 'countdown') {
12124		                var el_dday = $el.find('[data-dday="true"]'),
12125		                	cd_date = (el_dday.attr('data-countdown')) ? el_dday.attr('data-countdown') : new Date(),
12126		                    dateformat  = { days : '%D', hours: '%H', minutes: '%M', seconds: '%S' },
12127		                    dateendformat  = { days : '00', hours: '00', minutes: '00', seconds: '00' };
12128						
12129						if( typeof settings.countdown != 'undefined' && settings.countdown ) {  //set - block setting date 
12130	                        cd_date = settings.countdown;
12131		                }
12132		                if( !el_dday.attr('data-countdown') && typeof cd_date == 'object' ) { //set - example date
12133		                    cd_date.setTime(cd_date.getTime() + (35*24*60*60*1000));
12134		                }
12135			            cd_date = moment(cd_date).format('YYYY/MM/DD HH:mm:ss');
12136			            
12137						el_dday.countdown(cd_date, function(event) {
12138							$(this).find('.date-item[data-datetype]').each(function(i) {
12139								var dd_type = $(this).attr('data-datetype'),
12140									dd_format = $(this).attr('data-format'),
12141									dd_endformat = $(this).attr('data-finish');
12142
12143								if(typeof dd_format == 'undefined' || !dd_format) dd_format = dateformat[dd_type];
12144								if(typeof dd_endformat == 'undefined' || !dd_endformat) dd_endformat = dateendformat[dd_type];
12145
12146								if(event.elapsed) $(this).text(dd_endformat);
12147								else $(this).text(event.strftime(dd_format));
12148							});
12149						});
12150                		if($el.find('[data-bg-video="true"]').length > 0) resizeVideoIframe($el);
12151					}
12151 else if (c.type == 'latest') {
12152						var latest_data = (typeof settings.latest_data != 'undefined' && settings.latest_data) ? settings.latest_data : {};
12153						$.latest.init(c.seq,latest_data);					
12154					} else if (c.type == 'review') {
12155						_this.galleryEL[c.seq] = {
12156							'seq' : c.seq,
12157							'elname' : c.elname,
12158							'eltag' : c.eltag,
12159							'folder' : c.folder,
12160							'mode' : c.mode,
12161							'elsettings' : c.elsettings,
12162							'feature' : c.feature,
12163							'type' : c.type,
12164							'type2' : c.type2,
12165							'searches' : c.searches
12166						};
12167		                var gallery_data = (typeof settings.gallery_data != 'undefined' && settings.gallery_data) ? settings.gallery_data : {};
12168                		$.reviewContents.init(c.seq, gallery_data);
12169		            } else if (c.type == 'form' || (c.type == 'contact' && c.type2 == 'franchise bar')) {
12170						$.forms.init(c.seq);
12171		            } else if (c.type == 'contact') {
12172		            	if(c.type2 == 'franchise map') {
12173		            		$.each($el.find('[data-fmap-loop="true"] .item .item-name'), function(i, v) {
12174		                        let itemName = $(v).html();
12175		                        itemName = itemName.replace(/&lt;&nbsp;/g, '&lt;').replace(/&nbsp;&gt;/g, '&gt;');
12176		                        $(v).html(itemName);
12177		                    });
12178		                    
12179		            		var $mapItem = $el.find('[data-fmap-loop="true"] > .item.selected');
12180                    		drawMap($mapItem, $el);
12181                    		fmapMobilePaging($el);
12182		            	}
12183		            } else if (c.type == 'calendar') {
12184						var currentDate = new Date(),
12185							getYear = currentDate.getFullYear(),
12186							getMonth = String(currentDate.getMonth() + 1).padStart(2, "0"),
12187							yearMonth = getYear + '-' + getMonth;
12188						$.cl_calendar.init(c.sid, c.seq, yearMonth, c);
12189					} else if (c.type == 'showcase') {
12190						if($el.hasClass('carousel') && $el.find('.item').length > 1 && $el.find('.control-box .carousel-control').hasClass('hide')) {
12191							$el.find('.control-box .carousel-control').removeClass('hide');
12192						}
12193
12194						slideEffectClassAdd($el);
12195					}
12196
12197					if($el.find('.slick').length > 0) {
12198						if (c.type == 'sync' && typeof syncSlickFn == 'function') syncSlickFn('.' + c.elname);
12199						else if($el.is('[data-clslick]') && typeof clSlickFn == 'function') clSlickFn('.' + c.elname);
12200					}
12201
12202					if(data_aos_attr) {
12203						$el.removeClass('aos-animate');
12204						$el.addClass('render-aos');
12205						setTimeout(function(){
12206							$el.removeClass('render-aos').addClass('aos-animate');
12207						})
12208						$el.attr('data-aos-dummy', data_aos_attr)
12209					}
12210
12211					// console.log(c.seq, c.type, settings);
12212					if($.inArray(c.type, ['contents', 'text', 'image', 'video', 'sns']) > -1) {
12213	            		let ecs = enableContentsSlider(c.seq, c.type, settings);
12214						if(typeof settings.list_type != 'undefined' && settings.list_type == 's' && ecs) {
12215							// console.log('enable slider');
12216		                    $.contentsSlider.ready(c.seq).then(() => {$.contentsSlider.init(c.seq, settings)});
12217		                }
12218		            }
12219
12220					changeBrokenImages($el);
12221
12222		            idx++;
12223		    	});
12224
12225				
12226				// $('.tag.preloading').replaceWith(function () {
12227				//     return $(this).html();
12228				// });
12229
12230				if(check_modoo) {
12231					m_floating(fl_data);
12232				}  else if (property?.SETTINGS?.modoo?.floating) { // 모두 사이트 메뉴 디자인 변경 시 dsgn-body에 modoo가 포함되지 않아 모바일에서 퀵메뉴 안 보이는 문제 해결					        
12233					m_floating(fl_data);
12234				}
12235
12236				$('.preloading').removeClass('preloading');
12237				document.querySelectorAll('.element video').forEach(function(video) {
12238					if(video.readyState > 0) video.classList.add('loaded');
12239					video.addEventListener('loadeddata', function() {
12240						this.classList.add('loaded');
12241					});
12242				});
12243
12244				// b.ISLOCK = (!b.VALIDPLAN) ? 'false' : b.ISLOCK;
12245				if(b.ISLOCK == 'true') {
12246					$('.locked').remove();
12247					return deferred.resolve({'showOnlyFooter':true});
12248				}
12249				
12250            	if($('.element:not([data-type2="franchise map"]) [data-map_kind="kakao"]').length && (typeof kakao == 'undefined' || typeof kakao.maps == 'undefined' || 
12250kakao.maps == null || property.VALIDPLAN == '')) {
12251	                $('.element:not([data-type2="franchise map"]) [data-map_kind="kakao"]').html('지도연결해제됨. Javascript키 확인');
12252	                $('.element:not([data-type2="franchise map"]) [data-map_kind="kakao"]').html('<iframe class="google-map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3165.5659473821083!2d127.0282496015659!3d37.494568!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca1598c361b2b%3A0xdbf9af292beff3c!2z6rCV64Ko!5e0!3m2!1sko!2skr!4v1637303748377!5m2!1sko!2skr" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>');
12253	            } else {
12254					$('.element:not([data-type2="franchise map"]) [data-map_kind="kakao"]').each(function() {
12255						var container = this;
12256                        var lat = $(this).data("lat");
12257                        var lng = $(this).data("lng");
12258                        var zoomInOut = $(this).data("zoominout");
12259                        var mapTitle = $(this).data("maptitle");
12260                        var mapContent = $(this).data("mapcontent");
12261                        var useTitle = $(this).data("usetitle");
12262                        var useContent = $(this).data("usecontent");
12263
12264                        if (typeof zoomInOut == 'undefined' || !zoomInOut) zoomInOut = false;
12265                        if (typeof mapTitle == 'undefined' || !mapTitle) mapTitle = '';
12266                        if (typeof mapContent == 'undefined' || !mapContent) mapContent = '';
12267                        if (typeof useTitle == 'undefined' || !useTitle) useTitle = false;
12268                        if (typeof useContent == 'undefined' || !useContent) useContent = false;
12269                        
12270                        var options = { center: new kakao.maps.LatLng(lat, lng), level: 3 };
12271                        var c_map = new kakao.maps.Map(container, options);
12272                        var marker = new kakao.maps.Marker({ position: new kakao.maps.LatLng(lat, lng), map: c_map });
12273
12274		                if(zoomInOut == true) {
12275	                        var zoomControlHtml = '';
12276	                        zoomControlHtml += '\
12277	                            <div class="zoom-control" style="margin-top: 8px; margin-right: 8px; right: 0; width: 30px; position: absolute; background-color: #fff; z-index: 1; border-radius: 3px; box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);">\
12278	                                <div class="btn-zoom-control" data-inout="I" style="cursor: pointer; width: 30px; height: 30px;">\
12279	                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 11h-4V7c0-.55-.45-1-1-1s-1 .45-1 1v4H7c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1v-4h4c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>\
12280	                                </div>\
12281	                                <div class="slider-wrap-container" style="height: 130px;">\
12282	                                    <div class="slider-wrap small" style="text-align: center; height: 100%;">\
12283	                                        <div style="max-height: 100%;" class="zoom-control-slider"></div>\
12284	                                    </div>\
12285	                                </div>\
12286	                                <div class="btn-zoom-control" data-inout="O" style="cursor: pointer; width: 30px; height: 30px;">\
12287	                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 13H7c-.55 0-1-.45-1-1s.45-1 1-1h10c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>\
12288	                                </div>\
12289	                            </div>\
12290	                        ';
12291	                        var $zoomController = $(zoomControlHtml);
12292	                        $(container).append($zoomController);
12293	                        var zoom_slider = $zoomController.find('.zoom-control-slider').slider({
12294	                            'orientation': 'vertical',
12295	                            'min' : 1,
12296	                            'max' : 14,
12297	                            'step' : 1,
12298	                            'value' : 3,
12299	                            'handle' : '<div>dfafasdfas</div>',
12300	                            // 'reversed' : true,
12301	                            'tooltip' : 'hide',
12302	                        }).on('slide', function(data) {
12303	                            c_map.setLevel(data.value);
12304	                            c_map.setCenter(marker.getPosition());
12305	                        }).on('slideStop', function(data) {
12306	                            c_map.setLevel(data.value);
12307	                            c_map.setCenter(marker.getPosition());
12308	                        });
12309
12310	                        $zoomController.find('.btn-zoom-control').on('click', function() {
12311	                            if($(this).data('inout') == 'I') {
12312	                                c_map.setLevel(c_map.getLevel() - 1);
12313	                                zoom_slider.slider('setValue', c_map.getLevel());
12314	                            } else if($(this).data('inout' == 'O')) {
12315	                                c_map.setLevel(c_map.getLevel() + 1);
12316	                                zoom_slider.slider('setValue', c_map.getLevel());
12317	                            }
12318	                        });
12319
12320			                kakao.maps.event.addListener(c_map, 'zoom_changed', function() {
12321			                    zoom_slider.slider('setValue', c_map.getLevel());
12322			                });
12323		                }
12324
12325		                if((useTitle == true || useContent == true) && (mapTitle || mapContent)) {
12326		                    var iwContent = '';
12327		                    if(useTitle == true && mapTitle) {
12328		                        iwContent = '<div class="title">' + mapTitle + '</div>';
12329		                    }
12330		                    if(useContent == true && mapContent) {
12331		                        iwContent += '<div class="content">' + mapContent + '</div>';
12332		                    }
12333	                        if(iwContent) {
12334	                            iwContent = '<div class="contact-map-info-window"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 0C4.69 0 2 2.69 2 6s1 4 6 10c5-6 6-6.69 6-10s-2.69-6-6-6zm0 8.3a2.3 2.3 0 1 1 0-4.6 2.3 2.3 0 0 1 0 4.6z"></path></svg>
12334' + iwContent + '</div>';
12335	                            var infoWindow = $(iwContent);
12336	                            $(container).append(infoWindow);
12337	                        }
12338		                }
12339						$(window).on("resize", function() {
12340							c_map.relayout();
12341							c_map.setCenter(marker.getPosition());
12342						});
12343					});
12344				}
12345
12346	            if($('.element:not([data-type2="franchise map"]) [data-map_kind="naver"]').length && (typeof naver == 'undefined' || typeof naver.maps == 'undefined' || naver.maps == null || property.VALIDPLAN == '')) {
12347	                $('.element:not([data-type2="franchise map"]) [data-map_kind="naver"]').html('지도연결해제됨. Client ID 확인');
12348	                $('.element:not([data-type2="franchise map"]) [data-map_kind="naver"]').html('<iframe class="google-map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3165.5659473821083!2d127.0282496015659!3d37.494568!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca1598c361b2b%3A0xdbf9af292beff3c!2z6rCV64Ko!5e0!3m2!1sko!2skr!4v1637303748377!5m2!1sko!2skr" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>');
12349	            } else {
12350					$('.element:not([data-type2="franchise map"]) [data-map_kind="naver"]').each(function() {
12351						var container = this;
12352						var lat = $(this).data("lat");
12353						var lng = $(this).data("lng");
12354						var options = { center: new naver.maps.LatLng(lat, lng), zoom: 17};
12355		                var zoomInOut = $(this).data("zoominout");
12356		                var zoom = $(this).data("zoom");
12357		                var mapTitle = $(this).data("maptitle");
12358		                var mapContent = $(this).data("mapcontent");
12359		                var useTitle = $(this).data("usetitle");
12360		                var useContent = $(this).data("usecontent");
12361		                if(typeof zoomInOut == 'undefined' || !zoomInOut) zoomInOut = false;
12362		                if(typeof mapTitle == 'undefined' || !mapTitle) mapTitle = '';
12363		                if(typeof mapContent == 'undefined' || !mapContent) mapContent = '';
12364		                if(typeof useTitle == 'undefined' || !useTitle) useTitle = false;
12365		                if(typeof useContent == 'undefined' || !useContent) useContent = false;
12366						var c_map = new naver.maps.Map(container, options);
12367						var marker = new naver.maps.Marker({ position: new naver.maps.LatLng(lat, lng), map: c_map});
12368
12369		                if(zoomInOut == true) {
12370	                        var zoomControlHtml = '';
12371	                        zoomControlHtml += '\
12372	                            <div class="zoom-control" style="margin-top: 8px; margin-right: 8px; right: 0; width: 30px; position: absolute; background-color: #fff; z-index: 1; border-radius: 3px; box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);">\
12373	                                <div class="btn-zoom-control" data-inout="I" style="cursor: pointer; width: 30px; height: 30px;">\
12374	                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 11h-4V7c0-.55-.45-1-1-1s-1 .45-1 1v4H7c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1v-4h4c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>\
12375	                                </div>\
12376	                                <div class="slider-wrap-container" style="height: 130px;">\
12377	                                    <div class="slider-wrap small" style="text-align: center; height: 100%;">\
12378	                                        <div style="max-height: 100%;" class="zoom-control-slider"></div>\
12379	                                    </div>\
12380	                                </div>\
12381	                                <div class="btn-zoom-control" data-inout="O" style="cursor: pointer; width: 30px; height: 30px;">\
12382	                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 13H7c-.55 0-1-.45-1-1s.45-1 1-1h10c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>\
12383	                                </div>\
12384	                            </div>\
12385	                        ';
12386	                        var $zoomController = $(zoomControlHtml);
12387	                        $(container).append($zoomController);
12388	                        var zoom_slider = $zoomController.find('.zoom-control-slider').slider({
12389	                            'orientation': 'vertical',
12390	                            'min' : 6,
12391	                            'max' : 21,
12392	                            'step' : 1,
12393	                            'value' : 17,
12394	                            'handle' : '<div>dfafasdfas</div>',
12395	                            'reversed' : true,
12396	                            'tooltip' : 'hide',
12397	                        }).on('slide', function(data) {
12398	                            c_map.setZoom(data.value);
12399	                            c_map.setCenter(marker.getPosition());
12400	                        }).on('slideStop', function(data) {
12401	                            c_map.setZoom(data.value);
12402	                            c_map.setCenter(marker.getPosition());
12403	                        });
12404
12405	                        $zoomController.find('.btn-zoom-control').on('click', function() {
12406	                            if($(this).data('inout') == 'I') {
12407	                                c_map.setZoom(c_map.getZoom() + 1);
12408	                                zoom_slider.slider('setValue', c_map.getZoom());
12409	                            } else if($(this).data('inout' == 'O')) {
12410	                                c_map.setZoom(c_map.getZoom() - 1);
12411	                                zoom_slider.slider('setValue', c_map.getZoom());
12412	                            }
12413	                        });
12414
12415	                        naver.maps.Event.addListener(c_map, 'zoom_changed', function(zoom) {
12416	                            zoom_slider.slider('setValue', c_map.getZoom());
12417	                        });
12418		                }
12419		                
12420		                if((useTitle == true || useContent == true) && (mapTitle || mapContent)) {
12421		                    var iwContent = '';
12422		                    if(useTitle == true && mapTitle) {
12423		                        iwContent = '<div class="title">' + mapTitle + '</div>';
12424		                    }
12425		                    if(useContent == true && mapContent) {
12426		                        iwContent += '<div class="content">' + mapContent + '</div>';
12427		                    }
12428	                        if(iwContent) {
12429	                            iwContent = '<div class="contact-map-info-window"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 0C4.69 0 2 2.69 2 6s1 4 6 10c5-6 6-6.69 6-10s-2.69-6-6-6zm0 8.3a2.3 2.3 0 1 1 0-4.6 2.3 2.3 0 0 1 0 4.6z"></path></svg>
12429' + iwContent + '</div>';
12430	                            var infoWindow = $(iwContent);
12431	                            $(container).append(infoWindow);
12432	                        }
12433		                }
12434						$(window).on("resize", function() {
12435							// c_map.relayout();
12436							c_map.setCenter(marker.getPosition());
12437						});
12438					});
12439				}
12440
12441				$('.element [data-map="true"]:not(iframe)').each(function() {
12442					var map_url = $(this).attr('data-url');
12443					if(typeof map_url != 'undefined' && map_url) {
12444						var map_iframe = getMapURL(map_url,'html');
12445						$(this).replaceWith(map_iframe);
12446						if(map_iframe.indexOf('google-map disabled') === -1) $(this).next('.map-undefined').remove();
12447					}
12448				});
12449                
12450				if($('.element a[data-popup][data-popup-name]').length > 0 && (!b.VALIDPLAN || b.VALIDTYPE == 'PK')) {
12451					$('.element a[data-popup][data-popup-name]').addClass('disabled');
12452				}			
12453				if($('.element[data-layout]').length > 0) {
12454	                setLayoutHeight();
12455	            }
12456	            // if($('.element[data-parallax="true"]').length > 0 && $('.element[data-parallax-type="scroll"]').length > 0) setParallax();
12457				if(typeof setBlockParallax == 'function') setBlockParallax($('.element'));
12458
12459		    	$('.dsgn-body').fitVids();
12460				if(window.clTextCount && window.clTextCount.init) {
12461					window.clTextCount.init($('.dsgn-body').get(0) || document, true);
12462				}
12463
12464				if($('.element[data-aos]').length > 0) scheduleBlockAOSRefresh();
12465				$('html').toggleClass('gtoolbar-sticky-ON', $('.cl-gtoolbar[data-sticky="ON"]').length > 0 ? true : false);
12466				deferred.resolve();
12467		    });			
12468		});
12469		//parallax();
12470	    return deferred.promise();
12471    },
12472    setLoginout : function (show, sid, site, profileimg) {
12473		if(show=='1') {
12474			$.getJSON('/template/checkLogin', function(data) {
12475				if(data.user && site) {
12476					if($('#tpl-menu').find('.loginout')) $('#tpl-menu').find('.loginout').remove();
12477					setLoginoutNav(sid, function() {
12478						getProfileMember();
12479						getProfileAuthor(sid,profileimg);
12480						$('.el_0').css('margin-top','55px');
12481					});
12482				} else {
12483					$('#tpl-menu').append('<li class="loginout"><a href="javascript:;" title="CREATORLINK login"><i class="fa fa-user"></i></a></li>'); 
12484				}
12485			});
12486	    }
12487    },
12488    liveUpdate : function(obj) {
12489    	// console.log('liveUpdate');
12490
12491    	var b = this.b;
12492		if ($.isArray(obj) && b.SETTINGS && b.SETTINGS.modoo && !$.isEmptyObject(b.SETTINGS.modoo)) {
12493			obj = $.extend(true, [], obj);
12494			removeModooDuplicateChildren(obj, b.SETTINGS);
12495		}
12496		$.psearch = $.psearch || {};
12497		if(typeof $.psearch.normalizeHref != 'function') {
12498			$.psearch.normalizeHref = function(href) {
12499				href = (href || '').toString().trim();
12500				if(!href) return '';
12501
12502				href = href.replace(/^\/render/i, '');
12503				href = href.split('#')[0].split('?')[0];
12504
12505				if(/^https?:\/\//i.test(href)) {
12506					try { href = new URL(href).pathname; } catch(e) {}
12507				}
12508
12509				href = href.replace(/\/view\/\d+$/i, '');
12510
12511				if(href && href.charAt(0) !== '/') href = '/' + href;
12512				return href;
12513			};
12514		}
12515		if(typeof $.psearch.buildMenuBreadcrumbMap != 'function') {
12516			$.psearch.buildMenuBreadcrumbMap = function(menuOption) {
12517				var map = {};
12518				if(!menuOption || !menuOption.length) return map;
12519
12520				for(var i = 0; i < menuOption.length; i++) {
12521					var m = menuOption[i];
12522					var mainName = (m && m.name) ? m.name : '';
12523					var mainHref = $.psearch.normalizeHref(m && m.href);
12524
12525					if(mainHref) {
12526						map[mainHref] = $.lang[LANG]['editor.resource.icon.home'] + ' > ' + mainName;
12527					}
12528
12529					var children = (m && m.children) ? m.children : [];
12530					for(var j = 0; j < children.length; j++) {
12531						var c = children[j];
12532						var subName = (c && c.name) ? c.name : '';
12533						var subHref = $.psearch.normalizeHref(c && c.href);
12534
12535						if(subHref) {
12536							map[subHref] = $.lang[LANG]['editor.resource.icon.home'] + ' > ' + mainName + ' > ' + subName;
12537						}
12538					}
12539				}
12540				return map;
12541			};
12542		}
12543
12544		var checkSidebar = $('.el-menu > header').hasClass('sidebar'),
12545			checkClnav =  $.clnav.check(),
12546			menu_class = {
12547				'navlist': (checkClnav) ? 'cl-nav-list ' : '',
12548				'navitem': (checkClnav) ? 'cl-nav-item ' : '',
12549				'subnavlist': (checkClnav) ? 'cl-subnav-list ' : '',
12550				'subnavitem': (checkClnav) ? 'cl-subnav-item ' : '',
12551			},
12552			menu = (checkClnav) ? $('.el-menu > header.cl-nav .cl-nav-list') : $('#tpl-menu'),
12553	        idx = 0,
12554	        regex = /^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/,
12555	        regex2 = /^((http(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/;
12556	    menu.empty();
12557    	
12558		if($('.fmcss').length > 0) $('.fmcss').remove(); //forum background css
12559
12560			var addMenuPages = function(level) {
12561				$.each(level || [], function (idx, obj) {
12562					if(obj.name == '전체상품') {
12563						if(b.LUX || b.VALIDTYPE != 'SM' || !b.SLANG || (typeof b.SLANG.select_code !== 'undefined' && b.SLANG.select_code != 'ko')){
12564							return true;
12565						}
12566					}
12567
12568					b.MENULIST.push(getRenderMenuPage(obj));
12569					if(obj.children && obj.children.length > 0) addMenuPages(obj.children);
12570				});
12571			};
12572			addMenuPages(obj);
12573
12574		if(b.ONE) {
12575			linkUrl = (b.VIEW) ? '/#' : '#';
12576			linkUrl = (b.VIEW && !b.PUBLISH) ? '/render/index#' : linkUrl;
12577		} else {
12578			linkUrl = (b.URL=='/') ? '/' : b.URL + '/';  
12579		}
12580
12581		for (i = 0; i < obj.length; i++) {
12582	            var menuPage = getRenderMenuPage(obj[i]);
12583	            var link = menuPage;
12584				if(isRenderMenuPageLink(link, b.MENULIST)) link = normalizeRenderMenuLinkPage(link);
12585			
12586            if(link == '전체상품') {
12587	            if(b.LUX || b.VALIDTYPE != 'SM' || !b.SLANG || (typeof b.SLANG.select_code !== 'undefined' && b.SLANG.select_code != 'ko')) {
12588	                continue;
12589	            }
12590	        }
12591
12592			var parent = b.PAGE.split(',');
12593			var link_text = '';
12594			var target = '';
12595			var name = (checkClnav) ? `<span class="cl-nav-name">${obj[i].name}</span>` : obj[i].name;
12596			var menuPageAttr = (checkClnav) ? ` data-menu-page="${menuPage}"` : '';
12597			var menuUid = getRenderMenuUid(obj[i]);
12598			var menuUidAttr = (menuUid) ? ` data-menu-link-id="${menuUid}"` : '';
12599			var isInner = '';
12600			var isBookmark = '';
12601			var isFlink = '';
12602			var isFolder = '';
12603
12604			if(i==0) {
12605				if(obj[i].display=='on') {
12606					b.MENUCHECK.intro = true;
12607					b.MENULINK.push(link);
12608				}
12609				continue;
12610			}
12611
12612			if(obj[i].name =='전체상품') {
12613	            obj[i].link = '';
12614	        }
12615
12616			var active = (link == b.PAGE || link == parent[0]) ? 'active' : '';
12617			var sub = obj[i].children.length;
12618			if (obj[i].display == 'on') {
12619				b.MENUCHECK.main = true;
12620
12621				var menuoption_child = [];
12622				var tabmenuEnabled = isSiteMenuTabmenuEnabled(obj[i]);
12623				var menuLink = (!tabmenuEnabled && typeof obj[i].link != 'undefined') ? obj[i].link : '';
12624				var checkLink = (menuLink) ? true : false;
12625				var menuLinkPage = normalizeRenderMenuLinkPage(menuLink);
12626				var checkLinkInner = (checkLink && $.inArray(menuLinkPage, b.MENULIST) > -1) ? true : false;
12627				var checkLinkBookmark = (menuLink.match(/^\@/g) !== null) ? true : false;
12628				var checkLinkFile = (menuLink.match(/^flink\@[0-9]/gi) !== null) ? true : false;
12629				var checkLinkFolder = (menuLink === 'folder-menu') ? true : false;
12630
12631				link = (checkLink) ? ((checkLinkInner) ? menuLinkPage : menuLink) : link;
12632				isInner = (checkLinkInner) ? menuLinkPage : '';
12633				isBookmark = (checkLinkBookmark) ? ` attr-bookmark="${link.replace(/^\@/g,'')}"` : '';
12634				isFlink = (checkLinkFile) ? ` attr-flink="${link.replace(/^flink\@/gi,'')}"` : '';
12635				isFolder = (checkLinkFolder) ? ` attr-folder="true"` : '';
12636				target = (obj[i].ltarget == '_blank') ? 'target="_blank"' : '';
12637
12638				if(checkLink && !checkLinkInner && !checkLinkBookmark) {												// link-type: link-out      ==> a[attr-link]
12639					if(checkBase64Encode(link)) link = Base64.decode(link);
12640				}
12641
12642				if(link == 'folder-menu') {
12643					link_text = 'javascript:;';
12644					target = '';
12645					if(typeof menu.closest('.navbar-menu-'+b.SID).attr('data-submenu') != 'undefined') target = ' data-toggle="dropdown" aria-expanded="false" data-submenu="true" ';
12646				} else {
12647					if(!checkLink) b.MENULINK.push(link);
12648					link_text = (b.MENULIST.includes(link)) ? linkUrl + link : (!regex2.test(link) && regex.test(link)) ? '//' + link : link;
12649				}
12650
12651	            if (sub) {
12652	                var sub_menu = '';
12653	                var sub_show = 0;
12654	                var firstTabmenuChild = null;
12655	                var tabmenuDefaultUid = getSiteMenuTabmenuDefaultUid(obj[i]);
12656
12657	                sub_menu = `<ul class="${menu_class['subnavlist']} dropdown-menu">\r\n`;
12658	                for (j = 0; j < obj[i].children.length; j++) {
12659	                    var child = obj[i].children;
12660						if (isModooDuplicateChild(obj[i], child[j], b.SETTINGS)) continue;
12661						var childMenuUid = getRenderMenuUid(child[j]);
12662						var ignoreChildLink = tabmenuEnabled && tabmenuDefaultUid && childMenuUid == tabmenuDefaultUid;
12663						var childMenuLink = (!ignoreChildLink && typeof child[j].link != 'undefined') ? child[j].link : '';
12664						var checkChildLink = (childMenuLink) ? true : false;
12665							var childMenuLinkPage = normalizeRenderMenuLinkPage(childMenuLink);
12666							var checkChildLinkInner = (checkChildLink && b.MENULIST.includes(childMenuLinkPage)) ? true : false;
12667						var checkChildLinkBookmark = (childMenuLink.match(/^\@/g) !== null) ? true : false;
12668						var checkChildLinkFile = (childMenuLink.match(/^flink\@[0-9]/gi) !== null) ? true : false;
12669						var childPage = getRenderMenuPage(child[j]);
12670							var child_link = (checkChildLink) ? ((checkChildLinkInner) ? childMenuLinkPage : childMenuLink) : '';
12671							var child_isInner = (checkChildLinkInner) ? childMenuLinkPage : '';
12672						var child_isBookmark = (checkChildLinkBookmark) ? ` attr-bookmark="${child_link.replace(/^\@/g,'')}"` : '';
12673						var child_isFlink = (checkChildLinkFile) ? ` attr-flink="${child_link.replace(/^flink\@/gi,'')}"` : '';
12674						var sub_link = (child_link) ? child_link : childPage;
12675						var sub_target = (!ignoreChildLink && child[j].ltarget == '_blank') ? 'target="_blank"' : '';
12676						var sub_name = (checkClnav) ? `<span class="cl-subnav-name">${child[j].name}</span>` : child[j].name;
12677						var subPageAttr = (checkClnav) ? ` data-menu-page="${childPage}"` : '';
12678						var subMenuUidAttr = (childMenuUid) ? ` data-menu-link-id="${childMenuUid}"` : '';
12679						var sub_active = '';
12680						var sub_link_text = '';
12681
12682						if(checkChildLink && !checkChildLinkInner && !checkChildLinkBookmark) {							// link-type: link-out      ==> a[attr-link]
12683							if(checkBase64Encode(child_link)) sub_link = Base64.decode(child_link);
12684						}
12685
12686						var page_arr = (b.VIEW) ? b.PAGE.split(',') : [b.PAGE];
12687						if (!active && (sub_link == page_arr[0] || link == parent[0])) {
12688							sub_active = 'active';
12689							active = 'open';
12690							if(!checkClnav && $('body').width() > 768) active = 'active';
12691						}	                    	
12692
12693	                    if (child[j].display == 'on') {
12694							b.MENUCHECK.sub = true;
12695							if(!checkChildLink) b.MENULINK.push(childPage);
12696	                        sub_link_text = ($.inArray(sub_link,b.MENULIST) > -1) ? linkUrl+sub_link : (!regex2.test(sub_link) && regex.test(sub_link)) ? '//'+sub_link : sub_link;
12697
12698							if(firstTabmenuChild === null || (tabmenuDefaultUid && childMenuUid == tabmenuDefaultUid)) {
12699								firstTabmenuChild = {
12700									href: sub_link_text,
12701									target: sub_target,
12702									isinner: child_isInner,
12703									isbookmark: child_isBookmark,
12704									isflink: child_isFlink
12705								};
12706							}
12707
12708							sub_menu += `
12709								<li class="${menu_class['subnavitem'] + sub_active}"${subPageAttr + subMenuUidAttr}><a href="${sub_link_text}" ${sub_target + child_isBookmark + child_isFlink + subPageAttr + subMenuUidAttr}>${sub_name}</a></li>\r\n
12710							`;
12711	                        sub_show++;
12712
12713							menuoption_child.push({
12714								'idx0': b.MENUOPTION.length,
12715								'idx1': menuoption_child.length,
12716								'name': child[j].name,
12717								'page': childPage,
12718								'active': sub_active,
12719								'href': sub_link_text,
12720								'target': sub_target,
12721								'isinner': child_isInner,
12722								'isbookmark': child_isBookmark,
12723								'isflink': child_isFlink,
12724								'depth': 1,
12725								'menu_uid': childMenuUid,
12726								'topmobile': child[j].topmobile,
12727							});
12728	                    }
12729	                }
12730	                sub_menu = sub_menu +'</ul>\r\n';
12731
12732	                if(tabmenuEnabled && firstTabmenuChild !== null) {
12733	                    link_text = firstTabmenuChild.href;
12734	                    target = firstTabmenuChild.target;
12735	                    isInner = firstTabmenuChild.isinner;
12736	                    isBookmark = firstTabmenuChild.isbookmark;
12737	                    isFlink = firstTabmenuChild.isflink;
12738	                    isFolder = '';
12739	                }
12740
12741	                var caret = (checkSidebar) ? ' <i class="fa fa-caret-right fa-1" aria-hidden="true"></i>' : ' <i class="fa fa-caret-down fa-1" aria-hidden="true"></i>';
12742	                
12743					if (sub_show) {
12744                		var sub_menu_open = (typeof menu.closest('.navbar-menu-'+b.SID).attr('data-submenu') != 'undefined' && menu.closest('.navbar-menu-'+b.SID).attr('data-submenu') == 'open' && active != 'open') ? 'open' : '';
12745						menu.append(`\r\n<li class="${menu_class['navitem'] + active + sub_menu_open} dropdown"${menuPageAttr + menuUidAttr}><a href="${link_text}" class="dropdown-toggle" ${target + isBookmark + isFlink + menuPageAttr + menuUidAttr}>${name + caret}</a></li>\r\n`);
12746	                } else {
12747	                    menu.append(`\r\n<li class="${menu_class['navitem'] + active}"${menuPageAttr + menuUidAttr}><a href="${link_text}" ${target + isBookmark + isFlink + menuPageAttr + menuUidAttr}>${name}</a></li>\r\n`);
12748	                }
12749	                if(sub_show) menu.find('.dropdown:last').append(sub_menu);
12750	            } else {
12751	                menu.append(`\r\n<li class="${menu_class['navitem'] + active}"${menuPageAttr + menuUidAttr}><a href="${link_text}" ${target + isBookmark + isFlink + menuPageAttr + menuUidAttr}>${name}</a></li>\r\n`);
12752	            } 
12753
12754				b.MENUOPTION.push({
12755					'idx0': b.MENUOPTION.length,
12756					'name': obj[i].name,
12757					'page': menuPage,
12758					'active': active,
12759					'href': link_text,
12760					'target': target,
12761					'isinner': isInner,
12762					'isbookmark': isBookmark,
12763					'isflink': isFlink,
12764					'isfolder': isFolder,
12765					'depth': 0,
12766					'children': menuoption_child,
12767					'menu_uid': menuUid,
12768					'modooParentEntry': !!obj[i].modooParentEntry,
12769					'topmobile': obj[i].topmobile,
12770				});
12771
12772	            idx++;
12773	        }
12774		}
12775
12776
12777		// menu ver3 : fheader
12778		//              - Add #fixed-menu, #mobile-nav
12779		//              - Set mobile-design
12780		if ($.clnav.check()) $.clnav.init();
12781		else if ($('header.navbar').hasClass('navbar-fheader')) $.fheader.init();
12782
12783		if(	typeof b.VALIDPLAN != 'undefined' && b.VALIDPLAN && 
12784			typeof b.VALIDTYPE != 'undefined' && b.VALIDTYPE != 'PK'
12785		) {
12786			if(b.VALIDTYPE == 'SM') {
12787				$.umember.init(b.SITEUM,b.SITEUMLANG,b.SITEUMDISPLAY, function() { 
12788					$.psearch.init();
12789					$.shopping.init();
12790					$.slang.init(b.SLANG);
12791				});
12792			} else if(b.VALIDTYPE == 'BN') {
12793				$.umember.init(b.SITEUM,b.SITEUMLANG,b.SITEUMDISPLAY, function() { 
12794					$.slang.init(b.SLANG); 
12795				});
12796			} else {
12797				$.slang.init(b.SLANG);
12798			}
12799		} else {
12800			$.slang.init();
12801		}
12802
12803		// menu ver3 : fheader
12804		//             - Set site page top padding
12805		//             - Set menu config btn position
12806			if ($('header.navbar').hasClass('navbar-fheader')) $.fheader.set();
12807
12808			syncRenderUserLinksByMenuUid(b.SMENU, b.ONE, b.VIEW);
12809		    $('header .navbar-nav').removeClass('hide').removeClass('preloading');
12810		    $('body,html').animate({scrollTop: 0}, 300,'easeInOutQuart');
12811
12812	},
12813	syncUpdate : function($el,data) {
12814		$('#el-empty').empty().append($el.outerHTML());
12815		var $sync = $('#el-empty'),
12816			nodes = $sync.find('.item'),
12817			$sync_row = ($sync.find('.sync-option').length > 0) ? $sync.find('.sync-row') : $sync.find('.slick'),
12818            $sync_loop = $sync.find('[data-sync-loop="true"]'),
12819            checkSyncGalleryFrame = false,
12820            checkSyncHtmlReplace = false,
12821            sync_gallery = {},
12822            p = _this.b.RESOURCE + '/' + _this.b.SID + '/';
12823		
12824		checkSyncHtmlReplace = ($sync.find('input.sync-option').length > 0 && $sync.find('.layout-container').length == 0) ? true : false;
12825		setOldVerBlockView($sync,data);
12826
12827		if(typeof data.sync !='undefined' && typeof data.sync.list != 'undefined' && (data.sync.list).length) {
12828			$sync_row.empty();
12829			var nodes_count = nodes.length;
12830			$.each(data.sync.list, function(i,v) {
12831				var nodes_pos = i % nodes_count,
12832					$item = $(nodes[nodes_pos]);
12833				var imgbg_check = (typeof $item.find('.img-bg').attr('style') == 'undefined') ? false : true,
12834					href = '/' + v.page + '/view/' + v.seq,
12835					alink = (_this.b.PUBLISH) ? href : '/render' + href;
12836
12837                switch(v.type) {
12838                    case "gallery":
12839                        var img = getServeImage(v.image,'0',p);
12840                        (v.mode == 'project') ?
12841                            $item.find('a').attr('href', alink) :
12842                            $item.find('a').attr('href', img).attr('data-gallery','').attr('data-title',v.title); 
12843                        break;
12844                    case "shopping":
12845                    	if(typeof data.sync.member_only[v.pid] != 'undefined' && data.sync.member_only[v.pid] == 'ON') {
12846                        	if(_this.b.UMEMBER.check_login == true) {
12847                        		$item.find('a').attr('href',alink);
12848                        	} else {
12849                        		$item.find('a').attr('href','javascript:member_only_item();');
12850                        	}
12851                        } else $item.find('a').attr('href',alink);
12852                        break;
12853
12854                    case "lux":
12855                        $item.find('a').attr('href',(_this.b.PUBLISH) ? '/_product/' + v.seq : '/render/_product/' + v.seq);
12856                        break;
12857                }
12858                var brand_name = (v.brand_name != 'undefined' && v.brand_name && v.brand_name != '-') ? v.brand_name : '';
12859				$item.find('img').attr('src',v.image);
12860				$item.find('.brand').html(brand_name);
12861				$item.find('.name').html(v.title);
12862				$item.find('.caption').html(v.caption);
12863
12864                if(v.type == 'gallery' && v.mode == 'gallery') {
12865                    checkSyncGalleryFrame = true;
12866                    sync_gallery.elsettings = v.elsettings;
12867                    sync_gallery.type = 'gallery';
12868                }
12869                if(typeof data.sync.member_only[v.pid] != 'undefined' && data.sync.member_only[v.pid] == 'ON' && _this.b.UMEMBER.check_login == false) {
12870                    $item.find('.price').addClass('hidden');
12871                    $item.find('.sale').addClass('hidden');
12872                    $item.find('.price-sale').addClass('hidden');
12873	                } else {
12874	                    var syncGsettings = (typeof v.gsettings != 'undefined' && v.gsettings) ? $.parseJSON(v.gsettings) : {};
12875	                    var syncBlockSettings = {};
12876	                    if (data && data.element && data.element.elsettings) {
12877	                        try {
12878	                            syncBlockSettings = (typeof data.element.elsettings == 'string') ? $.parseJSON(data.element.elsettings) : data.element.elsettings;
12879	                        } catch(e) {
12880	                            syncBlockSettings = {};
12881	                        }
12882	                    }
12883	                    var baseSyncPrice = (v.price !== '') ? Number(v.price) : 0;
12884	                    var baseSyncSalePrice = (v.sale > 0 && v.sale >
12884 baseSyncPrice) ? Number(v.sale) : 0;
12885	                    var syncPrice = baseSyncPrice;
12886	                    var syncSalePrice = baseSyncSalePrice;
12887	                    var syncSaleLabel = (v.sale_rate > 0) ? v.sale_rate + '%' : '';
12888	                    var syncGradePrice = 0;
12889	                    var syncGradeApplied = false;
12890	                    var syncGradeDisplay = syncBlockSettings.grade_price_display == 'ON';
12891	                    var syncGrade = getShoppingGradePreviewDiscountGrade(data.grade);
12892	                    var productGradeOnOff = getShoppingGradeProductGradeOnOff(v);
12893	                    $item.attr('data-editor-grade-price-enabled', productGradeOnOff).attr('data-config-grade-price-enabled', productGradeOnOff);
12894
12895	                    if (
12896	                        baseSyncPrice > 0 &&
12897	                        isShoppingGradeProductGradePriceEnabled(v)
12898	                    ) {
12899	                        syncGradePrice = calcShoppingGradeDisplayPrice(baseSyncPrice, syncGrade);
12900	                        syncGradeApplied = syncGradePrice !== null;
12901	                    }
12902
12903	                $item.find('.price').text('₩' + number_format(syncPrice));
12904
12905                    if(syncSaleLabel) {
12906                        $item.find('.sale').removeClass('hide hidden').text(syncSaleLabel);
12907                    } else {
12908                        if($item.find('.sale').parent().hasClass('img-content')) $item.find('.sale').addClass('hide');
12909                        else $item.find('.sale').addClass('hidden');
12910                        $item.find('.sale').text('');
12911                    }
12912					$item.find('.price-unit-pricing').remove();
12913					if(v.product_unit_str) {
12914						var tmp_unit_selector = ($item.find('ul.price-wrap').length > 0) ? `ul.price-wrap` : `.content`,
12915							tmp_unit_wrap = ($item.find('ul.price-wrap').length > 0) ? `li` : `div`;
12916						$item.find(tmp_unit_selector).append(`<${tmp_unit_wrap} class="price-unit-pricing">${v.product_unit_str}</${tmp_unit_wrap}>`); // 단위당 가격
12917					}
12918
12919					if(syncSalePrice > 0 && syncSalePrice > syncPrice) {
12920                        $item.find('.price-sale').removeClass('hidden hide').text('₩' + number_format(syncSalePrice));
12921                    } else {
12922	                    $item.find('.price-sale').addClass('hidden').text('');
12923                    }
12924
12925					$item.find('.grade-discount-price').remove();
12926					if(syncGradeDisplay && syncGradeApplied) {
12927						var syncGradeWrap = ($item.find('ul.price-wrap').length > 0) ? 'ul.price-wrap' : '.content',
12928							syncGradeTag = ($item.find('ul.price-wrap').length > 0) ? 'li' : 'div';
12929						$item.find(syncGradeWrap).append('<' + syncGradeTag + ' class="grade-discount-price"><span class="grade-discount-price-value">₩' + syncGradePrice.toString().replace(/\B(?=(\d{3})+(?!\d))/g,',') + '</span><span class="grade-discount-price-label">나의 할인가</span></' + syncGradeTag + '>');
12930					}
12931                }
12932
12933                if(imgbg_check) $item.find('.img-bg').attr('style','background-image: url("' + v.image + '"');
12934				if($item.find('.sync-label-number').length > 0) $item.find('.sync-label-number').text(i+1);
12935                if(v.soldout) $item.find('.soldout').removeClass('hidden');
12936				$sync_row.append($item.outerHTML());
12937
12938				if(data.type2 == 'imgpitem' && $sync_loop.length > 0) {
12939					if($sync_loop.children('li').eq(i).length == 0) $sync_loop.append($sync_loop.children('li').eq(0).clone().removeClass('active'));
12940					$sync_loop.children('li').eq(i).attr('data-idx',i);
12941				}
12942                checkSyncHtmlReplace = true;				
12943			});
12944
12945            if(checkSyncGalleryFrame && typeof sync_gallery.type != 'undefined') {
12946                appendGalleryFrame($sync, data.seq, sync_gallery.type, sync_gallery.elsettings);
12947            }
12948            if(checkSyncHtmlReplace) tag = $sync.html();			
12949		}
12950		var r = $('#el-empty > .element:eq(0)').html();
12951		$('#el-empty').empty();
12952		// console.log(r);
12953		return r;		
12954	},
12955	galleryUpdate : function(el,data) {
12956		// console.log(`galleryUpdate: el`,el);
12957		var _this = this;
12958		$('#el-empty').append($(data.source));
12959		$('#el-empty').find('[data-loop="true"]').html('');
12960
12961		var checkGalleryListSample = false,
12962			checkGalleryListEmpty = true,
12963			source = data.source,
12964			nodes = $(source).find('[data-loop="true"]').children('.grid'),
12965			p = $('#el-empty').children(),
12966			g = p.clone().removeClass().addClass('galleryPL'+el.seq).addClass('gallery-popup'),
12967            i = [],
12968            view = $(source).find('[data-loop="true"]').data('view'),
12969            g_number = $(tag).find("[data-loop='true']").data('gallery-no'),
12970            total = (typeof data.total != 'undefined' && data.total) ? data.total : 0;
12971
12972        $('#el-empty').after(g);
12973        $(g).after('<div class="gallery-empty"></div>');
12974
12975        if(typeof view == 'undefined') view = 10;
12976
12977        var g_settings = (typeof el.elsettings == 'undefined' || el.elsettings == '') ? {} : $.parseJSON(el.elsettings),
12978        	cookie_page = 1,
12979            cookie_view = view,
12980            cookie_gallery_category = '',
12981            is_gc_cookie = (typeof $.cookie('gallery-category-'+el.seq) != 'undefined' && $.cookie('gallery-category-'+el.seq).length > 0) ? true : false,
12982            block_lang = (typeof g_settings.blocklang != 'undefined') ? g_settings.blocklang : LANG,
12983            field_oldver = (typeof g_settings.field_oldver != 'undefined' && g_settings.field_oldver.length > 0) ? g_settings.field_oldver : [];
12984            field_disable = (typeof g_settings.field_disable != 'undefined' && g_settings.field_disable.length > 0) ? g_settings.field_disable : [];
12985        var cookie_gallery_orderby = 'recent';
12986
12987		var category_onoff = (typeof g_settings.category_display != 'undefined' && g_settings.category_display) ? g_settings.category_display : 'OFF';
12988        var gallery_sort = (typeof g_settings.gallery_sort != 'undefined' && g_settings.gallery_sort) ? g_settings.gallery_sort : 'default';
12989		if(el.mode != 'shopping' && gallery_sort == 'product') gallery_sort = 'default';
12990
12991		// var adultonly_onoff = (typeof g_settings.adult_only != 'undefined' && g_settings.adult_only) ? g_settings.adult_only : 'OFF';
12992        if(	category_onoff == 'ON' &&
12993        	typeof $.cookie('ci_goto-gallery') != 'undefined' && $.cookie('ci_goto-gallery') == el.seq &&
12994        	typeof $.cookie('ci_goto-gallery-cate') != 'undefined' && g_settings.category.indexOf('|' + $.cookie('ci_goto-gallery-cate') + '|') > -1 &&
12995        	typeof g_settings.category != 'undefined' && g_settings.category 
12996    	) {
12997        	cookie_gallery_category = $.cookie('ci_goto-gallery-cate');
12998        	is_gc_cookie = true;
12999        } else if($.cookie('loadmore-' + el.seq)) {
13000			cookie_page = $.cookie('loadmore-'+el.seq);
13001			cookie_gallery_category = (typeof $.cookie('gallery-category-'+el.seq) != 'undefined') ? $.cookie('gallery-category-'+el.seq) : '';
13002            cookie_gallery_orderby = (typeof $.cookie('gallery-orderby-' + el.seq) != 'undefined') ? $.cookie('gallery-orderby-' + el.seq) : '';
13003			cookie_view = cookie_page * view;
13004        } else { 
13005			var checkCateHomeHide = (category_onoff == 'ON' &&
13006									typeof g_settings.category != 'undefined' && g_settings.category && 
13007									typeof g_settings.category_home_hide != 'undefined' && g_settings.category_home_hide) ? true : false;
13008			if(checkCateHomeHide) {
13009				var gc = g_settings.category.replace(/\|/g,'').split(',');
13010				cookie_gallery_category = gc[0];
13011				is_gc_cookie = true;
13012
13013				$.cookie('gallery-catehome-' + el.seq, cookie_gallery_category, { path : '/', expires: 12 * 60 * 60 * 1000 });
13014			}
13015        }
13016
13017        if(el.seq == 'all_products') {
13018        	// cookie_page = (typeof $.cookie('gallery-page-all_products') !== 'undefined' && $.cookie('gallery-page-all_products') != '')? $.cookie('gallery-page-all_products') : 1;
13019        	cookie_gallery_category = getAllProductsSortVal(g_settings);
13020        	// cookie_view = cookie_page * view;
13021        } else {
13022        	if(!property.VIEW) $.removeCookie('gallery-page-all_products', { path: '/' });
13023        }
13024
13025		$.cookie('gallery-page-' + el.seq, cookie_page, { path : '/', expires: 12 * 60 * 60 * 1000 });
13026		$.cookie('gallery-category-' + el.seq, cookie_gallery_category, { path : '/', expires: 12 * 60 * 60 * 1000 });
13027	    $.cookie('gallery-orderby-' + el.seq, cookie_gallery_orderby, { path: '/', expires: 12 * 60 * 60 * 1000 });
13028        $.removeCookie('loadmore-' + el.seq, { path : '/' });
13029
13030        var checkLoadmoreInLoop = ($(source).find('[data-loop="true"] .loadmore-wrap').length) ? true : false;
13031        var glm = $(source).find('.loadmore-wrap');
13032
13033		var checkGallerySVG = ($(source).find('.gimg-svg-wrap').length > 0) ? true : false,
13034			checkGFrameTitleOFF = (el.mode == 'gallery' && (typeof g_settings.gframe_title_visible != 'undefined' && g_settings.gframe_title_visible == 'OFF')) ? true : false;
13035
13036		var param = (el.page=='index,template' && property.param.indexOf('/org/') == -1) ? property.param + '/org/' + el.page : property.param;
13037		var post_data = { g_mode: el.mode, visible: true, sfl: 'category', stx: cookie_gallery_category };
13038
13039		if(el.seq == 'all_products') {
13040			post_data = { g_mode: el.mode, visible: true, sfl: 'orderby', stx: cookie_gallery_category };
13041		}
13042
13043		var g_data = {
13044			'list' : property.CONTENTS['el' + el.seq]['list'],
13045			'total' : property.CONTENTS['el' + el.seq]['total']
13046		}
13047
13048		var checkUseComment = checkUseCommentFunc(el.mode, el.eltag);
13049		var checkUseLike = checkUseLikeFunc(el.mode, el.eltag);
13050		
13051		$.each(g_data.list, function (idx, v) {
13052			i.push(v);
13053		});
13054		
13055		total = (typeof g_data.total.list_total != 'undefined') ? g_data.total.list_total : g_data.total;
13056		// total = (typeof g_data.total.list_total != 'undefined') ? g_data.total.list_total : 0;
13057		cookie_view = (cookie_view < total) ? cookie_view : total;
13058
13059		if( total > 0 ) checkGalleryListEmpty = false;
13060		if( i.length>0 || (i.length==0 && is_gc_cookie) ) {
13061			var loop_count = nodes.length, item_index = 0, elem = [];
13062			$.each(g_data.list,function(index,v) {
13063				// console.log(v);
13064				loop_pos = index%loop_count;
13065				c = nodes[loop_pos];
13066				var isTitle = (v.title.length > 0) ? true:false;
13067				$(c).find('.non_text').removeClass('non_text');
13068
13069				if(el.mode != 'shopping') {
13070					if(v.title.length==0) $(c).find('.figure.title').removeClass('non_text').addClass('non_text');
13071					if(v.caption.length==0) $(c).find('.figure.caption').removeClass('non_text').addClass('non_text');
13072				}
13073
13074				v.title = (v.title.length>0) ? v.title : $.lang[block_lang]['editor.block.gallery.sample.title'];
13075				v.caption = (v.caption.length>0) ? v.caption : $.lang[block_lang]['editor.block.gallery.sample.caption'];
13076
13077				$(c).addClass('gallery-item').attr('data-index',index).attr('data-seq',v.seq);
13078				
13079
13080				var vgsettings = (typeof v.gsettings != 'undefined' && v.gsettings) ? $.parseJSON(v.gsettings) : {},
13081					img_path = (typeof vgsettings['storage'] != 'undefined') ? vgsettings['storage'] : _this.b.RESOURCE + '/' + _this.b.SID + '/',
13082					img_original = (typeof vgsettings['storage'] != 'undefined') ? img_path + '1920/' : img_path;
13083				
13084				var folder = (typeof data.element.folder == 'undefined' || data.element.folder == 0) ? '' : data.element.folder + '/',
13085					src = getServeImage(v.image,data.element.folder,img_path),
13086					src_s0 = getServeImage(v.image,'0',img_path);
13087				if($(c).find('img').length > 0) $(c).find('img').attr('src',src);
13088
13089				if(el.mode == 'shopping') {
13090					if($(c).find('img').length > 0) $(c).find('img').attr('alt',v.title);
13091				} else if(typeof v.alt != 'undefined') {
13092				    alt_replace	= v.alt.replace(/\s+|\n+/g, '-');  
13093      				alt_replace.replace(/-+/g, '-')	
13094					if($(c).find('img').length > 0) $(c).find('img').attr('alt',alt_replace);						
13095				}
13096				ensureGalleryResponsiveImageClass($(c));
13097
13098				if($(c).find('.g-img').length > 0) $(c).find('.g-img').css('background-image', 'url('+src+')');
13099				if(checkGallerySVG) {
13100					var gimgSVG = $(c).find('.gimg-svg-wrap svg');
13101					gimgSVG.find('pattern').attr('id','gimgSvg_'+el.elname+'_'+index);
13102					gimgSVG.find('image').attr('xlink:href', src);
13103					gimgSVG.find('polygon, path').attr('fill', 'url(#gimgSvg_'+el.elname+'_'+index+')');					
13104				}
13105
13106				var glink = (typeof vgsettings['glink'] != 'undefined' && vgsettings['glink']) ? vgsettings['glink'] : '',
13107					glink_target = (typeof vgsettings['glink_target'] != 'undefined' && vgsettings['glink_target']) ? vgsettings['glink_target'] : '';
13108
13109				if(glink) {
13110					if(glink.match(/^\@/g) !== null) {															// link-type: link-bookmark ==> a[attr-bookmark]
13111						var bookmark_seq = glink.replace(/^\@/g,'');
13112						if(typeof _this.b.SETTINGS.blockBookmarkList == 'undefined' || typeof _this.b.SETTINGS.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
13113							glink = '';
13114							glink_target = '';
13115						}
13116					} else if(glink.match(/^flink\@[0-9]/gi) !== null) {										// link-type: link-file     ==> a[attr-flink]
13117						glink_target = '';
13118						} else if(isRenderMenuPageLink(glink, _this.b.MENULIST)) {	// link-type: link-menu     ==> a[data-user-link]
13119					} else {																					// link-type: link-out      ==> a[attr-link]
13120						if(checkBase64Encode(glink)) glink = Base64.decode(glink);
13121					}
13122				}
13123
13124				$(c).find('a').removeAttr('data-gallery').removeAttr('data-user-link').removeAttr('attr-bookmark').removeAttr('attr-link').removeAttr('attr-flink');
13125
13126				// var gallery_page_chmod = JSON.parse(property.CONTENTS['el' + v.pid]['element']['elsettings']).gallery_page_chmod,
13127				// 	umgrade = property.UMGRADE['grade_seq'];
13128				var entry =	(property && property.CONTENTS && property.CONTENTS['el' + v.pid]) || (property && property.CONTENTS && property.CONTENTS[String(v.pid)]) || null;
13129				var elsettingsRaw = entry && entry.element ? entry.element.elsettings : null;
13130				var elsettingsObj = elsettingsRaw;
13131
13132				if (typeof elsettingsRaw === 'string') {
13133					try { elsettingsObj = JSON.parse(elsettingsRaw); }
13134					catch (e) { console.error('[ERR] elsettings JSON 파싱 실패:', e, elsettingsRaw); elsettingsObj = {}; }
13135				}
13136
13137				var gallery_page_chmod = elsettingsObj && elsettingsObj.gallery_page_chmod || null;
13138				var umgrade = property && property.UMGRADE ? (property.UMGRADE.seq || property.UMGRADE.grade_id || null) : null;
13139				if (typeof gallery_page_chmod === 'string') {
13140					try { gallery_page_chmod = JSON.parse(gallery_page_chmod); }
13141					catch (e) { gallery_page_chmod = gallery_page_chmod ? gallery_page_chmod.split(',') : []; }
13142				}
13143				gallery_page_chmod = $.isArray(gallery_page_chmod) ? $.map(gallery_page_chmod, function(v) { return String(v); }) : [];
13144				umgrade = (umgrade !== null && typeof umgrade != 'undefined') ? String(umgrade) : null;
13145
13146				$(c).removeClass('noneShoppingGrade').removeAttr('data-shopping-grade-msg');
13147				if (isShoppingGradePriceHidden(v) && property['SITEUM'] >= 1) {
13148					$(c).addClass('gallery-item').addClass('nonePrice');
13149					$(c).find('a').attr('href', '#');
13150				} else {
13151
13152					if(isShoppingGradeBlocked(v, el.seq == 'all_products' ? g_settings : elsettingsObj, property)) { //쇼핑등급
13153						$(c).addClass('gallery-item').addClass('noneShoppingGrade');
13154						$(c).attr('data-shopping-grade-msg', getShoppingGradeBlockedMessage(v));
13155						$(c).find('a').attr('href', '#');
13156					} else {
13157						if(glink) {
13158							var glink_val = makeLinkUrl(glink, _this.b.ONE, _this.b.VIEW);
13159							$(c).find('a').attr('href',glink_val);
13160
13161							if(glink.match(/^\@/g) !== null) {
13162								$(c).find('a').attr('attr-bookmark',glink.replace(/^\@/g,''));
13163							} else if(glink.match(/^flink\@[0-9]/g) !== null) {
13164								$(c).find('a').attr('attr-flink',glink.replace(/^flink\@/g,''));
13165							// IE ERROR_includes__H.20210603
13166							// } else if(_this.b.MENULIST.includes(glink.replace(/ /g,'-'))) {
13167							} else if(isRenderMenuPageLink(glink, _this.b.MENULIST)) {
13168								$(c).find('a').attr('data-user-link',glink_val);
13169							} else {
13170								$(c).find('a').attr('attr-link',glink);
13171							}
13172						} else {
13173							if (el.mode == 'gallery') {
13174								src_s0 = src_s0 + '?gpos='+v.pos;
13175
13176								$(c).find('a').attr('href', src_s0);
13177								$(c).find('a').attr('data-gallery', '#gframe-' + el.seq);
13178							} else {
13179								if(el.seq == "all_products") {
13180									$(c).find('a').attr('href', v.product_url);
13181								} else {
13182									if(typeof URI == 'function') URI = '/';
13183									if(_this.b.LUX && el.mode == 'shopping') $(c).find('a').attr('href', ((_this.b.URL=='/') ? '' : _this.b.URL) + '/_product/' + v.seq);
13184									else $(c).find('a').attr('href', ((_this.b.URL=='/') ? '' : _this.b.URL) + '/' + _this.b.PAGE + '/view/' + v.seq);
13185								}
13186							}
13187						}
13188					}
13189				}
13190
13191				if(glink_target == '_blank') $(c).find('a').attr('target','_blank');
13192				else $(c).find('a').removeAttr('target');
13193
13194				if(checkGFrameTitleOFF || !isTitle) $(c).find('a').attr('data-title', '');
13195				else $(c).find('a').attr('data-title', v.title);
13196
13197				// if(adultonly_onoff == 'ON') $(c).addClass('adultonly');
13198
13199				// caption
13200				var ftitle = $(c).find('h5.figure'),
13201					fcaption = $(c).find('p.figure').not('.comment'),
13202					fdatetime = $(c).find('.figure.datetime'),
13203					fhashtag = $(c).find('.figure.hashtag'),
13204					fbrand = $(c).find('.figure.brand'),
13205					fprice = $(c).find('.figure.price'),
13206					freview = $(c).find('.figure.review'),
13207					fcomment = $(c).find('.figure.comment'),
13208					flike = $(c).find('.figure.like'),
13209					fbasket = $(c).find('.figure.basket');
13210
13211				$(c).find('figcaption').removeClass('hide');
13212				
13213				if (v.title || v.caption) {
13214					var gallery_caption = v.caption;
13215					gallery_caption = gallery_caption.trim().replace(/\n/g,'<br />');
13216					
13217					ftitle.html(v.title);
13218					fcaption.html(gallery_caption);
13219					if(fdatetime.length > 0) fdatetime.text(v.datetime);
13220					if(fhashtag.length > 0) fhashtag.text(v.hashtag);
13221				}
13222
13223				if(g_number) {
13224					var g_index = String(index + 1),
13225						g_num = g_index.padStart(g_number, '0');
13226					$(c).find('.figure.number').text(g_num);
13227				}
13228
13229				if(fbrand.length > 0) {
13230					var fbrand_name = (typeof v.brand_name != 'undefined' && v.brand_name) ? v.brand_name : '';
13231					fbrand.html(v.brand_name);
13232				}
13233
13234				if(el.mode == 'shopping' || el.seq == 'all_products') {
13235					fcomment.addClass('hide');
13236					flike.addClass('hide');
13237
13238						v.price = typeof v.price != 'undefined' ? parseFloat(v.price) : 0;
13239						v.sale = typeof v.sale != 'undefined' ? parseFloat(v.sale) : 0;
13240						var productGradeOnOff = getShoppingGradeProductGradeOnOff(v);
13241						$(c).attr('data-editor-grade-price-enabled', productGradeOnOff).attr('data-config-grade-price-enabled', productGradeOnOff);
13242
13243						var checkPriceHidden = isShoppingGradePriceHidden(v),
13244							base_gallery_price = (v.price && !checkPriceHidden) ? v.price : 0,
13245							base_gallery_sale_price = (typeof v.sale != 'undefined' && v.sale > 0 && v.sale > v.price && !checkPriceHidden) ? v.sale : 0,
13246							gallery_price = base_gallery_price,
13247							gallery_sale_price = base_gallery_sale_price,
13248							gallery_sale_per = (typeof v.sale_per != 'undefined' && v.sale_per && !checkPriceHidden) ? v.sale_per+'%' : '',
13249							grade_price_display = g_settings.grade_price_display == 'ON',
13250							grade_discount_grade = getShoppingGradePreviewDiscountGrade(data.grade),
13251							grade_discount_applied = false,
13252							grade_gallery_price = 0,
13253							product_soldout = '품절',
13254							product_no_sale = (typeof g_settings.sh_soldout == 'string') ? g_settings.sh_soldout : '구매불가',
13255							product_status = '';
13256						if (
13257							!checkPriceHidden &&
13258							isShoppingGradeProductGradePriceEnabled(v)
13259						) {
13260							grade_gallery_price = calcShoppingGradeDisplayPrice(base_gallery_price, grade_discount_grade);
13261							grade_discount_applied = grade_gallery_price !== null;
13262						}
13263					if(v.status == 'off' && !checkPriceHidden) {
13264						product_status = '<span class="cl-sh-soldout">' + product_no_sale + '</span>';
13265					} else if(v.quantity_on == 'on' && v.quantity < 1 && !checkPriceHidden) {
13266						product_status = '<span class="cl-sh-soldout">' + product_soldout + '</span>';
13267					}
13268
13269					$(c).find('.cl-sh-soldout').remove();
13270					if(product_status != '') $(c).attr('data-soldout',true);
13271					else $(c).removeAttr('data-soldout');
13272
13273					$(c).find('.product-badge').remove();
13274					product_status += drawBadgeList(v.use_badge, data.badge_settings);
13275
13276					$(c).find('.cl-sh-limit').remove();
13277					if(v.status == 'lim') {
13278                        if(v.sale_now == false) {
13279                            var product_limit = '<p class="cl-sh-limit">상품 구매 가능 기간이 아닙니다.</p>';
13280                            if(freview.length > 0) {
13281                                freview.after(product_limit);
13282                            } else {
13283                                $(c).find('figcaption:not(.top) .figure:last-child').after(product_limit);
13284                            }
13285                        }
13286                    }
13287
13288					if($(c).find('ul.figure.price').length > 0) {
13289						// var price_off = (v.sale_price > 0 && v.sale_price > v.price) ? 100 - Math.floor((v.price / v.sale_price) * 100) : 0,
13290						//         off_str = (price_off > 0) ? price_off + '% ' : ''
13291									var off_str = (v.sale_rate > 0) ? v.sale_rate + '% ' : '';
13292									if(!_this.b.LUX) off_str = gallery_sale_per;
13293									if(!off_str && gallery_sale_price > 0 && gallery_price > 0 && gallery_price < gallery_sale_price) {
13294										var price_off = Math.round(((gallery_sale_price - gallery_price) / gallery_sale_price) * 100);
13295										off_str = (price_off > 0) ? price_off + '% ' : '';
13296									}
13297									//Ver2
13298									if(!checkPriceHidden) {
13299										var $priceWrap = $(c).find('ul.figure.price'),
13300											$priceVal = $priceWrap.find('.price-val'),
13301											$priceSale = $priceWrap.find('.price-sale'),
13302											$priceSalePer = $priceWrap.find('.price-sale-per');
13303										$priceWrap.find('.sp-price, .grade-discount-price').remove();
13304										if($priceSale.length > 0 && $priceSalePer.length == 0) {
13305											$priceSale.after('<li class="price-sale-per hide"></li>');
13306											$priceSalePer = $priceWrap.find('.price-sale-per');
13307										}
13308										$priceWrap.css({display:'', flexDirection:'', alignItems:''});
13309										$priceVal.css({order:'', display:''});
13310										$priceSale.css({order:'', display:'', marginRight:''});
13311										$priceSalePer.css({order:'', display:'', marginLeft:'', marginTop:''});
13312											$priceVal.html('₩' + gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,','));
13313										$priceVal.removeClass('hide');
13314
13315										if(gallery_sale_price > 0 && gallery_price < gallery_sale_price) {
13316											$priceSale.html('₩' + gallery_sale_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,','));
13317												$priceSalePer.html(off_str);
13318											$priceSale.removeClass('hide');
13319												$priceSalePer.removeClass('hide');
13320											if(!grade_discount_applied && _this.b.LUX && (v.hashtag).indexOf('특가세일') > -1 && $(c).find('ul.figure.price .sp-price').length == 0) {
13321												$(c).find('ul.figure.price .price-sale').after('<li class="sp-price">특가세일</li>');
13322											}
13323										} else {
13324											$priceSale.addClass('hide').html('');
13325											$priceSalePer.addClass('hide').html('');
13326
13327										}
13328							
13329							if(grade_price_display && grade_discount_applied) {
13330								$priceWrap.append('<li class="grade-discount-price"><span class="grade-discount-price-value">₩' + grade_gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,',') + '</span><span class="grade-discount-price-label">나의 할인가</span></li>');
13331							}
13332
13333							$(c).find('ul.figure.price .price-unit-pricing').remove();
13334							if(v.product_unit_str) {
13335								$(c).find('ul.figure.price').append(`<li class="price-unit-pricing">${v.product_unit_str}</li>`); // 단위당 가격
13336							}
13337						} else {
13338							$(c).find('ul.figure.price .price-val').html('₩0');
13339							$(c).find('ul.figure.price .price-val').addClass('hide');
13340						}
13341						if(el.seq == 'all_products' && checkPriceHidden) $(c).find('ul.figure.price').html('');
13342						if(product_status) $(c).find('ul.figure.price').append('<li>'+product_status+'</li>');
13343
13344						var badge_size = getBadgeSize(data.badge_settings);
13345						$(c).find('.cl-sh-soldout').removeClass('badge-small badge-medium badge-large');
13346						$(c).find('.cl-sh-limit').removeClass('badge-small badge-medium badge-large');
13347						if(badge_size) {
13348							$(c).find('.cl-sh-soldout').addClass(badge_size);
13349							$(c).find('.cl-sh-limit').addClass(badge_size);
13350						}
13351					} else {
13352						//Ver1
13353						if(fprice.length == 0) fprice = fcaption;
13354						if(checkPriceHidden) fprice.html('');
13355						else fprice.html('<span class="figure-krw">₩</span>' + gallery_price.toString().replace(/\B(?=(\d{3})+(?!\d))/g,',') + product_status);
13356					}
13357
13358					if($(c).find('ul.figure.review').length > 0) {
13359						var gallery_review = (v.review_onoff && v.review_cnt) ? v.review_cnt : 0;
13360						if(gallery_review > 0) {
13361							$(c).find('ul.figure.review, ul.figure.review li').removeClass('hide');
13362							$(c).find('ul.figure.review .figure-review-cnt').html(gallery_review);
13363							$(c).find('ul.figure.review .figure-review-score').html(v.review_score);
13364						} else {
13365							$(c).find('ul.figure.review, ul.figure.review li').addClass('hide');
13366							$(c).find('ul.figure.review .figure-review-cnt, ul.figure.review .figure-review-score').html('');
13367						}
13368					}
13369
13370					if(fbasket.length > 0) {
13371						var checkOldBlock = ($(c).find('.figure.basket[data-oldver="true"]').length > 0) ? true : false,
13372							checkOldverBasket = (typeof field_oldver != 'undefined' && field_oldver && field_oldver.indexOf('basket') > -1) ? true : false,
13373							checkDisabledBasket = (typeof field_disable != 'undefined' && field_disable && field_disable.indexOf('basket') > -1) ? true : false;
13374						if(v.basket_off || v.shopping_grade_hidden == 'ON') fbasket.addClass('cannotby hide');
13375						else if(el.seq == 'all_products') fbasket.removeClass('hide');
13376						else if(checkDisabledBasket || (!checkDisabledBasket && checkOldBlock && !checkOldverBasket)) fbasket.addClass('hide');
13377						else if(property.VALIDTYPE != 'SM') fbasket.addClass('hide');
13378						else fbasket.removeClass('hide');
13379					}
13380
13381				} else {
13382					fbrand.addClass('hide');
13383					fprice.addClass('hide');
13384					freview.addClass('hide');
13385					fbasket.addClass('hide');
13386
13387					if ( checkUseComment 
13388						&& g_settings.comment_display == 'ON'
13389						&& !(field_disable !== undefined && field_disable.indexOf('comment') > -1)
13390						&& fcomment.length > 0
13391						&& (typeof v.comment_cnt != 'undefined' && v.comment_cnt > 0)
13392					) {
13393						fcomment.removeClass('hide');
13394						fcomment.find('.figure-comment-cnt').html(v.comment_cnt);
13395					} else {
13396						fcomment.addClass('hide');
13397						fcomment.find('.figure-comment-cnt').empty();
13398					}
13399
13400					if ( checkUseLike 
13401						&& (g_settings.like_display !== undefined && g_settings.like_display != 'N')
13402						&& !(field_disable !== undefined && field_disable.indexOf('like') > -1)
13403						&& flike.length > 0
13404					) {
13405						flike.removeClass('hide').find('.figure-like-cnt').html(0);
13406						if(v.like !== undefined) {
13407							flike.find('.figure-like-cnt').html(v.like.cnt);
13408							if (v.like.own && v.like.cnt > 0) flike.attr('data-like', v.seq).addClass('active');
13409						}
13410					} else {
13411						flike.addClass('hide');
13412					}
13413				}
13414				
13415				if(checkUseLike == false) flike.html('');
13416
13417				if(el.mode == 'gallery') {
13418					if(index < data.view) {
13419						$(p).find('[data-loop="true"]').append($(c)[0].outerHTML); 
13420					} else {
13421						$(c).find('figure').remove();
13422						$(g).find('[data-loop="true"]').append($(c)[0].outerHTML);
13423					}
13424					if (total == 2) {
13425						$(c).find('figure').remove();
13426						$('.gallery-empty').append($(c)[0].outerHTML);
13427					}
13428				} else {
13429					$(p).find('[data-loop="true"]').append($(c)[0].outerHTML);
13430				}
13431			});
13432		} else {
13433			checkGalleryListSample = true;
13434			if(el.mode=='project' && _this.b.TEMPLATE == false) {
13435				nodes.addClass('gallery-item');
13436				nodes.find('a').attr('href', ((_this.b.URL=='/') ? '' : _this.b.URL) + '/' + _this.b.PAGE + '/view/template').removeAttr('data-gallery').find('img').attr('data-index',0);
13437			}
13438			if(_this.b.TEMPLATE !== false) {
13439				if ( checkUseComment 
13440					&& g_settings.comment_display == 'ON'
13441					&& !(g_settings.field_disable !== undefined && g_settings.field_disable.indexOf('comment') > -1)
13442				) {
13443					nodes.find('.figure.comment').removeClass('hide');
13444				} else {
13445					nodes.find('.figure.comment').addClass('hide');
13446				}
13447
13448				if ( checkUseLike 
13449					&& (g_settings.like_display !== undefined && g_settings.like_display != 'N')
13450					&& !(g_settings.field_disable !== undefined && g_settings.field_disable.indexOf('like') > -1)
13451				) {
13452					nodes.find('.figure.like').removeClass('hide');
13453				} else {
13454					nodes.find('.figure.like').addClass('hide');
13455				}
13456			}
13457			$(p).find('[data-loop="true"]').append(nodes);
13458
13459			if(_this.b.LUX) {
13460				category_onoff = 'ON';
13461				checkGalleryListSample = false;
13462			}
13463		}
13464		if(checkLoadmoreInLoop) $(p).find('[data-loop="true"]').append(glm);
13465
13466        var tag = $(p)[0].outerHTML;
13467        var $galleryEL = $('.element[data-id="' + el.seq + '"]');
13468
13469		if (el.mode == 'gallery' && total == 2) {
13470			$.each($('.gallery-empty').find('.gallery-item'), function(i,v) {
13471				$(g).find('[data-loop="true"]').append(v);
13472			});
13473		}
13474
13475		if (el.mode == 'gallery' && total) tag = appendGalleryFrame($(tag), el.seq, el.type, g_settings);
13476		$galleryEL.html($(tag).html()).removeClass('preloading');
13477		setOldVerBlockView($galleryEL,el);
13478
13479		$('#el-empty').empty();
13480		$('.gallery-empty').remove();
13481
13482		var $tag = $galleryEL.find('.shop-filter-header');
13483		if($tag.length) shopHeaderDisplay($tag,data);
13484
13485		$galleryEL.attr('data-category',category_onoff);
13486		$galleryEL.attr('data-gallery-sort',gallery_sort);
13487		
13488		if(category_onoff == 'ON' || gallery_sort == 'product') {
13489			initGToolbar($galleryEL, { id: el.seq, settings: g_settings });
13490		}
13491
13492		showHideGalleryField($galleryEL,g_settings);
13493		reloadBlockMasonry('init',$galleryEL);
13494
13495		var $glmBtnWrap = $galleryEL.find('.loadmore-wrap');
13496		var $glmBtn = $galleryEL.find('.loadmore-wrap .gallery-loadmore');
13497		var checkLoadmore = (total > view && total > cookie_view && !checkGalleryListEmpty) ? true : false;
13498		var glm_lang = LANG;
13499
13500		if(typeof g_settings.loadmore_lang != 'undefined' && g_settings.loadmore_lang && $.inArray(g_settings.loadmore_lang.toLowerCase(), ['ko','en']) > -1) glm_lang = g_settings.loadmore_lang.toLowerCase();
13501		else if(typeof block_lang != 'undefined' && $.inArray(block_lang, ['ko','en']) > -1) glm_lang = block_lang;
13502		var glm_txt = $.lang[glm_lang]['config.loadmore'];
13503
13504		if($glmBtnWrap.length == 0) {
13505			// gallery loadmore btn - default (ver1)
13506			if(checkLoadmore) {
13507				var glm_class = (el.feature=='masonry') ? 'gallery-loadmore masonry-layout' : 'gallery-loadmore',
13508				glm_btn = '<div class="' + glm_class + '" data-loadmore="true" data-selector=".gallery-loadmore" data-total="' + total + '" data-id="' + el.seq + '" data-page="' + (Number(cookie_page)+1) + '" data-view="' + view + '" data-folder="' + el.folder + '" data-mode="' + el.mode + '">' + glm_txt +' &nbsp;(<span class="display">' + cookie_view + '</span> / ' + number_format(total) + ')</div>';
13509
13510				if($galleryEL.find('.gallery-loadmore').length > 0) $galleryEL.find('.gallery-loadmore').replaceWith(glm_btn);
13511				else $galleryEL.append(glm_btn);
13512			} else $galleryEL.find('.gallery-loadmore').remove();
13513
13514		} else {
13515			// gallery loadmore btn - custom (ver2)
13516			if(checkLoadmore) {
13517				if(el.feature=='masonry') $glmBtn.addClass('masonry-layout');
13518				else $glmBtn.removeClass('masonry-layout');
13519				$glmBtn.attr('data-loadmore','true').attr('data-id',el.seq).attr('data-total',total).attr('data-page',Number(cookie_page)+1).attr('data-view',view).attr('data-folder',el.folder).attr('data-mode',el.mode);
13520				$glmBtn.find('.label').text(glm_txt);
13521				$glmBtn.find('.display .view').text(cookie_view);
13522				$glmBtn.find('.display .total').text(total);
13523				$glmBtnWrap.removeClass('hide').fadeIn();
13524			} else {
13525				$glmBtnWrap.fadeOut().addClass('hide');
13526				$glmBtn.removeAttr('data-loadmore').removeAttr('data-id').removeAttr('data-total').removeAttr('data-page').removeAttr('data-view').removeAttr('data-folder').removeAttr('data-mode').removeClass('masonry-layout');
13527				$glmBtn.find('.label').text(glm_txt);
13528				$glmBtn.find('.display .view').text('0');
13529				$glmBtn.find('.display .total').text('0');
13530			}
13531		}
13532
13533		if(el.seq == 'all_products') {
13534			if(property.ONE) $galleryEL.addClass('link-to-전체상품');
13535			setGToolbarAllProducts($galleryEL, g_settings, el.total.list_total);
13536		}
13537
13538		if($galleryEL.has('input.gjs').length) setGalleryJS('load-loop',$galleryEL);
13539	},
13540	forumUpdate : function(pid,page_num,view,page,data) {
13541		if(page_num > 1) {
13542			$.forum.init(pid, page, view, page_num,'', '', '');
13543		} else {
13544			$.forum.set(pid, page_num, view, page, '', '', '',data);
13545		}
13546	},
13547	displayComment : function(viewData) {
13548		if (typeof viewData == 'undefined' || !viewData) viewData = {};
13549		var checkUrl = this.b.PAGE.split(',');
13550		var type = (checkUrl[0] == 'forum') ? 'F' : 'P';
13551		var check_view_empty = (this.b.VIEW && this.b.COUNT == 1 && $('.error_404.element[data-name="error_404"]').length == 1) ? true : false;
13552		if(type == "P" 
13553			&& (this.b.COUNT == 0 || check_view_empty)
13554		) {
13555			$('.error_404.element[data-name="error_404"] *[data-lang]').each(function() {
13556				$(this).html($.lang[LANG][$(this).attr('data-lang')]);
13557			});
13558			return false;
13559		}
13560
13561	    var option = (this.b.PARENT.settings) ? jQuery.parseJSON(this.b.PARENT.settings) : {};  
13562
13563	    if(type == 'F') {
13564			if($.isEmptyObject(viewData) && this.b.PARENT.settings) viewData = {elsettings: jQuery.parseJSON(this.b.PARENT.settings)};
13565			let tmp_elsettings = getOrDefault(viewData,'elsettings',{});
13566	    	let tmp_fmsettings = getOrDefault(viewData,'fm_settings',{});
13567
13568			let comment_display = 'ON';
13569			if(getOrDefault(tmp_fmsettings,'comment_display','') != '') comment_display = tmp_fmsettings.comment_display;
13570			else if(getOrDefault(tmp_elsettings,'comment_display','') != '') comment_display = tmp_elsettings.comment_display;
13571
13572		    if(comment_display == 'OFF') return false;
13573	    } else {
13574			if(typeof option.comment_display == 'undefined' || option.comment_display == 'OFF') return false;
13575	    }
13576	     
13577	    $.comment.init();
13578	},
13579	loaded : function() {
13580		var b = _this.b;
13581		if($('body').width() <= 768 && $('.dsgn-body').hasClass('sidebar')) {
13582			if($('header.navbar').hasClass('sidebar')) {
13583				cssSidebar('off');
13584			}
13585			//$('.dsgn-body').removeClass('sidebar').addClass('removed-sidebar');
13586		} else if ($('body').width() > 768 /*&& $('.dsgn-body').hasClass('removed-sidebar')*/) {
13587			if($('header.navbar').hasClass('sidebar')) {
13588				cssSidebar('on');
13589			}
13590			//$('.dsgn-body').removeClass('removed-sidebar').addClass('sidebar');
13591		}
13592
13593		$('.carousel').live('click',function(){
13594		    $('.carousel').carousel('cycle');
13595		});
13596
13597		$('.carousel').live({
13598			click: function() {
13599				$('.carousel').carousel('cycle');
13600			},
13601			hover:  function(){
13602				$('.carousel').carousel('cycle');
13603			}
13604		});
13605
13606        $('.carousel').carousel({
13607        	pause: 'none'
13608        });
13609
13610        $('[data-fixed-width]').each(function() {
13611            $(this).css('width',$(this).attr('data-fixed-width')+'px');
13612        });
13613        
13614        SCREEN = getScreen();
13615        var targetUrl = document.URL,
13616        	isMoveLink = targetUrl.match(/#/g);
13617
13618        $('.menu-logo-top').show();
13619
13620		if(typeof $.cookie('gallery-return-page') != 'undefined' && b.VIEW == '') {
13621			restoreGalleryReturnTarget();
13622		} else if(typeof $.cookie('gallery-item') != 'undefined' && b.VIEW == '') {
13623    		moveGallery($.cookie('gallery-item'));
13624    	} else if(typeof $.cookie('forum-item') != 'undefined' && b.VIEW == '') {
13625    		// console.log('loaded', 'fm_view', $.cookie('forum_content_view'));	
13626    		if(typeof $.cookie('forum_content_view') != 'undefined'){
13627                var fm_view = $.cookie('forum_content_view');
13628                var fv = (fm_view !== undefined && fm_view)? fm_view.split('&'):array();
13629                var pid = (fv)? fv[0]:'';
13630                var row_id = (fv)? fv[1]:'';
13631
13632                setTimeout(function(){
13633                	scrollToBlock('.element[data-id="' + pid + '"] .tpl-forum-list-title[data-id="'+row_id+'"]', 1000);
13634                }, 500);
13635    			$.removeCookie('forum-item', { path : '/' });
13636
13637                $('.element[data-id="' + pid + '"] .tpl-forum-list-title[data-id="'+row_id+'"]').click();
13638            } else {
13639            	scrollToBlock('.element[data-id="' + $.cookie('forum-item') + '"]', 1000);
13640    			$.removeCookie('forum-item', { path : '/' });
13641            }
13642    	}   
13643
13644    	if($('body').width() > 768) {
13645    		$('.form-date').attr('type','text');
13646    		$('.form-date').attr('maxlength','2');
13647    		$('.date-yyyy').attr('maxlength','4');
13648    	}
13649
13650        $.modalOFF();
13651	},
13652	loadPage : function(page) {
13653
13654	}
13655}
13656
13657var aosAddblock = function(site_settings,settings,$el) {
13658	if($el.is('[data-type="gallery"][data-type2="premium"]') 
13659		|| $el.has('input.gjs').length 
13660		|| $el.is('.el-fixedcontact[data-type="contact"][data-type2="franchise bar"]')
13661	) {
13662		$el.attr('data-aosinfo',false);
13663		return false;
13664	}
13665
13666	var block_aos_site =  (typeof site_settings.block_aos != 'undefined' && site_settings.block_aos) ? site_settings.block_aos : {},
13667		block_aosAll_site =  (typeof block_aos_site['all'] != 'undefined' && block_aos_site['all']) ? block_aos_site['all'] : {},
13668		aos_time_site = (typeof block_aosAll_site.t != 'undefined' && block_aosAll_site.t) ? block_aosAll_site.t : '',
13669		aos_motion_site = (typeof block_aosAll_site.m != 'undefined' && block_aosAll_site.m) ? block_aosAll_site.m : '',
13670		aos_duration_site = (typeof block_aosAll_site.d != 'undefined' && block_aosAll_site.d) ? block_aosAll_site.d : '700';
13671
13672	var block_aos_page =  (typeof settings.block_aos != 'undefined' && settings.block_aos) ? settings.block_aos : {},
13673		aos_time_page = (typeof block_aos_page.t != 'undefined' && block_aos_page.t) ? block_aos_page.t : '',
13674		aos_motion_page = (typeof block_aos_page.m != 'undefined' && block_aos_page.m) ? block_aos_page.m : '',
13675		aos_duration_page = (typeof block_aos_page.d != 'undefined' && block_aos_page.d) ? block_aos_page.d : '700';
13676
13677
13678    if(block_aos_site && (aos_time_site > aos_time_page) && aos_motion_site!='no-motion' && 
13679    	$('body').find('.menu-lock-block').length<1 && $('body').find('.site-lock-block').length<1) { 
13680        $el.attr('data-aos',aos_motion_site)
13681        	.attr('data-aos-duration',aos_duration_site)
13682
13683    	if(aos_motion_site == 'fade-zoom-in' || aos_motion_page =='fade-zoom-in') {	            
13684	    	$el.attr('data-aos-easing','ease-in-back');
13685		}
13686		isAosBlock = true;
13687		$el.attr('data-aosinfo',true);
13688    } else {
13689        if($.isEmptyObject(block_aos_page) == false && (aos_time_site < aos_time_page) && aos_motion_page!='no-motion' && 
13690        	$('body').find('.menu-lock-block').length<1 && $('body').find('.site-lock-block').length<1) {
13691            $el.attr('data-aos',aos_motion_page)
13692            	.attr('data-aos-duration',aos_duration_page);
13693        	if(aos_motion_site == 'fade-zoom-in' || aos_motion_page =='fade-zoom-in') {	            
13694		    	$el.attr('data-aos-easing','ease-in-back');
13695			}
13696        	isAosBlock = true;
13697        	$el.attr('data-aosinfo',true);
13698        } else $el.attr('data-aosinfo',false);
13699    }
13700
13701	if(isAosBlock) {
13702		$('body,html').addClass('aos-height aos-overflowX');
13703	} else {
13704		$('body,html').removeClass('aos-height aos-overflowX');
13705	}
13706}
13707
13708var mobileWebfnavCheck = function(vpmode) {
13709	var checkFnav = ($('.fnav').length > 0 && vpmode=="mobile_web") ? true : false,
13710		WebType = isMobile();
13711                
13712	if(checkFnav && WebType) {
13713		$('.fnav.fnav-mobile-fnav').css('margin-bottom','53px');
13714		$('.element.el-footer').css('margin-bottom','100px');
13715	} else {
13716		$('.mobilepc_ch').css('margin-bottom','0px');
13717		$('.element.el-footer').css('margin-bottom','0px');
13718	}	
13719	
13720	if(WebType) {
13721		$('.element.el-footer').addClass('mpcwebheight');	
13722		$.mpcWeb.mpcMusicandGoTop(checkFnav,vpmode); 
13723	}
13724}
13725var mobileProductBtnPosition = function(property,device_type) {
13726	var quick_height = $(`.quick-menu-${property.SID}.quickmenu`).innerHeight();
13727
13728	if(device_type=='mobile') {
13729		var quick_height = $(`.quick-menu-${property.SID}.quickmenu`).innerHeight(),
13730			productBtn_height = $('.m-product-btn').innerHeight(),
13731			productBtn_position = ($.quickmenu['quickmenu']['img_type'][device_type]=='bottom_default') ? quick_height : '';
13732
13733		if($.quickmenu['quickmenu']['img_type'][device_type]=='bottom_default') $('.m-product-btn, .product-detail-btn').css('bottom',productBtn_position);
13734		else $(`.quick-menu-${property.SID}.quickmenu`).css('bottom',productBtn_height+30);
13735
13736	}
13737}
13738
13739var mobileWebQuickmenuPosition = function(property,device_type) {
13740	var check_music = (typeof property.SETTINGS.musicUse != 'undefined' && (property.SETTINGS.musicUse === true || property.SETTINGS.musicUse == 'true')) ? true : false,
13741		el_fixedheight = (typeof $.cookie(`fixedcontact-${property.SID}`) != 'undefined' && $.cookie(`fixedcontact-${property.SID}`) == 'off') ? 0 : $('.element.el-fixedcontact').innerHeight(),
13742		el_fixedonoffHeight = 22,
13743		quick_height = $(`.quick-menu-${property.SID}.quickmenu`).innerHeight(),
13744		mpc_height = (typeof property.SETTINGS.viewportMode != 'undefined' && property.SETTINGS.vpMode_onoff===true) ? $('.mobilepc_ch').innerHeight() : 0,
13745		check_mpc = (typeof property.SETTINGS.viewportMode != 'undefined' && property.SETTINGS.vpMode_onoff===true) ? true : false,
13746		quick_position = 12,
13747		gotop_position = 0,
13748		gotoTop_position = '';
13749
13750	el_fixedblockheight = el_fixedheight + el_fixedonoffHeight;
13751
13752	if($('.element.el-fixedcontact').length>0) {
13753		if(device_type=='pc') {
13754			gotop_position = el_fixedblockheight + 33;
13755		} else {
13756			var fixed_position = ($.quickmenu['quickmenu']['img_type'][device_type]=='bottom_default') ? quick_height : '';
13757			quick_position = (check_music) ? el_fixedblockheight + 45 : el_fixedblockheight + 30;
13758			quick_position = ($.quickmenu['quickmenu']['img_type'][device_type]=='bottom_default') ? 0 : quick_position;
13759			
13760			if(check_mpc) {
13761				var webtype = $.mpcWeb.mpcCheckWebType();
13762				if(webtype=='MOBILE') {											
13763					quick_position = (check_music) ? mpc_height + el_fixedblockheight + 45 : mpc_height + el_fixedblockheight + 10;
13764					if($.quickmenu['quickmenu']['img_type'][device_type]=='bottom_default') {
13765						quick_position = mpc_height;
13766						fixed_position = fixed_position + mpc_height;
13767					}
13768				}
13769			} 
13770			$('.element.el-fixedcontact').css('bottom',fixed_position);	
13771		}
13772	} else {
13773		gotop_position = (device_type=='pc') ? 42 : gotop_position;
13774		quick_position = '';
13775		if(check_mpc) {
13776			var webtype = $.mpcWeb.mpcCheckWebType();
13777			if(webtype=='MOBILE') {	
13778				if($.quickmenu['quickmenu']['img_type'][device_type]=='bottom_default') {
13779					quick_position = mpc_height;
13780				}
13781				else quick_position = (check_music) ? mpc_height + 45 : mpc_height + 30;
13782			}
13783		} 
13784	}
13785
13786	if(device_type=='pc') {
13787		$('#goto-top').css('bottom',gotop_position);
13788		quick_position = gotop_position + $('#goto-top').outerHeight() + 30;
13789
13790		if(check_mpc) {
13791			var webtype = $.mpcWeb.mpcCheckWebType();
13792			if(device_type=='pc' && webtype=='MOBILE') {
13793				quick_position = quick_position + mpc_height;
13794				$('.element.el-fixedcontact').css('bottom','');	
13795				$('#goto-top').css('bottom',gotop_position + mpc_height);
13796			}
13797		}
13798		
13799	} 
13800	
13801	$(`.quick-menu-${property.SID}.quickmenu`).css('bottom',quick_position);	
13802}
13803
13804var quickMenuMusicPosition = function(property) {
13805	var sid = (typeof property != 'undefined') ? property.SID : SID,
13806		vpModeOnoff = (property.SETTINGS.vpMode_onoff === true) ? true : false,
13807		webType = $.mpcWeb.mpcCheckWebType(),
13808		quick_type = ($('body').width() > 768) ? 'pc' : 'mobile';
13809
13810	var el_fixedheight = (typeof $.cookie(`fixedcontact-${sid}`) != 'undefined' && $.cookie(`fixedcontact-${sid}`) == 'off') ? 0 : $('.element.el-fixedcontact').innerHeight(),
13811		mpc_height = (vpModeOnoff && webType == 'MOBILE') ? $('.mobilepc_ch').innerHeight() : 0,
13812		el_fixedonoffHeight = 22,                
13813		el_fixedblockheight = 0,
13814		quick_position = 0,
13815		music_position = 5;
13816
13817	el_fixedblockheight = el_fixedheight + el_fixedonoffHeight;
13818	
13819
13820	if($('.element.el-fixedcontact').length > 0) {
13821		if(quick_type=='pc') {
13822			music_position = el_fixedheight + 5;
13823		} else {
13824			var quick_height = (typeof $.quickmenu['quickmenu'] != 'undefined' && $.quickmenu['quickmenu']['img_type'][quick_type]=='bottom_default') ? $(`.quick-menu-${sid}.quickmenu`).innerHeight() : 0;
13825			music_position = quick_height + el_fixedblockheight + 5;                    
13826			quick_position = music_position + $('#cl-music-player-icon').outerHeight() + 5;
13827	
13828			if(vpModeOnoff && webType == 'MOBILE') {	
13829				quick_position = mpc_height + quick_position;
13830			} 
13831			
13832			if(typeof $.quickmenu['quickmenu'] != 'undefined' && $.quickmenu['quickmenu']['img_type'][quick_type]!='bottom_default') $(`.quick-menu-${sid}.quickmenu`).css('bottom',quick_position);	
13833		}  
13834
13835		if(vpModeOnoff && webType == 'MOBILE') {	
13836			music_position = music_position + mpc_height;		
13837			quick_position = mpc_height + quick_position;
13838		} 
13839	} 
13840	$('#cl-music-player-icon, #cl-music-container').css('bottom',music_position);
13841}
13842
13843var setlimitdiskPopup = function() {
13844	var icon = '<i class="site-space-icon fa fa-exclamation-circle"></i>',
13845		str = '<div class="site-space-disk">\
13846					<p>
13846'+$.lang[LANG]['plan.disk-space.popup.limit.contents']+'</p>\
13847				</div>\
13848				';
13849
13850	$(this).showModalFlat(icon + $.lang[LANG]['plan.disk-space.popup.limit.title'], str,false,false).addClass('flat-site-spacelimit-modal');
13851	$('.modal-backdrop.in').css('opacity','0');
13852}
13853
13854var setSitePopup = function() {
13855    if(typeof property.SETTINGS != 'undefined' && property.SETTINGS.showPopup === true && typeof property.SETTINGS.sitePopup != 'undefined' && property.SITELOCK != 'true') {
13856        sitePopupOpen();
13857    }
13858}
13859
13860var sitePopupOpen = function(idx,data) {
13861	var site_popup = (typeof data != 'undefined' & data) ? data : new Array();
13862	if(site_popup.length == 0)  site_popup = (typeof property.SETTINGS.sitePopup != 'undefined' && property.SETTINGS.sitePopup) ? property.SETTINGS.sitePopup : site_popup;
13863	if(site_popup.length > 0) {
13864        $('.refresh-popup').show().removeAttr('style');
13865        var isShow = true;
13866
13867		if(typeof idx != 'undefined') {
13868			if($('#'+property.SID+'Popup'+idx).length == 0) isShow = false;
13869			else $('#'+property.SID+'Popup'+idx).fadeIn();
13870		} else {
13871
13872			if($('.site-popup .modal-popup').length > 0) { 
13873				$('.site-popup .modal-popup').fadeIn();
13874			} else { 
13875				isShow = false; 
13876			}
13877		}
13878
13879		if(!isShow) {
13880	        var modal = $(this).showPopupModal(site_popup,property.SID);
13881	        return modal;
13882	    }
13883	}
13884}
13885
13886var sitePopupResize = function() {
13887
13888	if($('.popup').find('.modal-popup').length == 0) return false;
13889	
13890	var img_w = new Array(),
13891		total_w = 0,
13892		add_w = 0,
13893		d_m = ($('.popup-modal').hasClass('popupimg-overflow-y')) ? 30 : 15;
13894		d_top = $('.header.el-menu').outerHeight() + 15,
13895		d_left = 0,
13896		x = 0, y = 0, y_r = 0;
13897
13898	$('.modal-popup').each(function(i) {
13899		if($(this).css('display') != 'none') {
13900			img_w[i] = $(this).width();
13901			total_w += img_w[i] + d_m;
13902		}
13903	});
13904
13905
13906	var isOverflow = ($('.dsgn-body').width() < (Number($('.popup-modal').children().eq(0).css('left').replace('px',''))+total_w)) ? true : false,
13907		display_i = -1;
13908
13909	if(isOverflow) { $('.popup-modal').addClass('popupimg-overflow-y');
13910	} else { $('.popup-modal').removeClass('popupimg-overflow-y'); }
13911
13912	$('.modal-popup').each(function(i) {
13913		if($(this).css('display') != 'none') {
13914			display_i++;
13915
13916			if(isOverflow) {
13917				x = (display_i==0) ? d_top : d_top + (display_i*30);
13918				y = d_left + ((display_i+1)*30);
13919				y_r = 120 - y;
13920
13921				img_w[i] = 'auto';
13922			} else {
13923				d_left = ($('.dsgn-body').width() - total_w)/2;
13924
13925				x = d_top;
13926				y = d_left + add_w + (i*15);
13927			}
13928			add_w = add_w + $(this).width();
13929
13930			var css_val = (isOverflow) ? {'top': x +'px', 'left': y+'px', 'right': y_r+'px', 'margin-left': '0px', 'width': img_w[i], 'max-width': $(this).width()} : {'top': x +'px', 'left': y+'px' , 'width': img_w[i]};
13931			$(this).css(css_val);
13932		}
13933	});
13934
13935}
13936
13937
13938var activeEL = function(el) {
13939    if(typeof el == 'undefined' || el=='') return;
13940    // header_fixed = $('header.navbar').height();
13941    // var offset = ($('.dsgn-body').hasClass('sidebar')) ? 0 : -header_fixed;
13942    // $('body').scrollTo('.'+el,0,{offset:offset});
13943   	scrollToBlock('.'+el);
13944}
13945
13946var setLoginoutNav = function (sid, callback) {
13947	$('.creatorlink-header').remove();
13948	$('#tpl-menu li.loginout').remove();
13949	var str = '<div class="creatorlink-header">\n';
13950	str = str + '<div class="logo-text col-md-4 col-sm-6">\n';
13951	str = str + '	<a href="http://creatorlink.net"><img src="https://storage.googleapis.com/i.addblock.net/main/site_creatorlink_logo.png" alt="" /></a>\n';
13952	str = str + '</div>\n';
13953	str = str + '<div class="data-site col-md-4 col-sm-6 col-xs-6">\n';
13954	str = str + '	<ul>\n';
13955	str = str + '		<li class="profile-img"></li>\n';
13956	str = str + '		<li><span class="text">' + sid + '</span></li>\n';
13957	str = str + '	</ul>\n';
13958	str = str + '</div>\n';
13959	str = str + '<div class="data-user col-md-4 col-sm-6 col-xs-6">\n';
13960	str = str + '	<ul class="pull-right">\n';
13961	str = str + '		<li class="profile-img"></li>\n';
13962	str = str + '		<li><span class="caret"></span></li>\n';
13963	str = str + '	</ul>\n';
13964	str = str + '	<div class="message"></div>\n';
13965	str = str + '</div>\n';
13966	str = str + '</div>\n';
13967	str = str + '\n';
13968	str = str + '\n';
13969	$('.header.el-menu').before(str);
13970	var top = ($('header').hasClass('transparent')) ? '0' : '55px';
13971	$('.header.el-menu').css('top',top);
13972	if(top == '0') $('.creatorlink-header + .popover + .fixed-position').css('top','0');
13973
13974	if(typeof callback == 'function') callback();
13975}
13976
13977var getProfileAuthor = function(sid,img) {
13978	var imgstr = (img == 'https://storage.googleapis.com/i.addblock.net/member/profile_default.jpg') ? 'https://storage.googleapis.com/i.addblock.net/member/profile_default_top.png' : img;
13979	var str = 		'<span class="hexagon">\n';
13980		str = str + '	<svg viewBox="0 0 32 32">\n';
13981		str = str + '		<pattern id="pfimg-" + sid +"" patternUnits="userSpaceOnUse" width="32" height="32">\n';
13982		str = str + '			<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href=""+imgstr+"" x="-2px" y="-2px" width="36" height="36"></image>\n';
13983		str = str + '		</pattern>\n';
13984		str = str + '		<polygon points="16 0 30 8 30 24 16 32 2 24 2 8" fill="url(#pfimg-" + sid +")"></polygon>\n';
13985		str = str + '	</svg>\n';
13986		str = str + '</span>\n';
13987	$('.data-site .profile-img').append(str);
13988}
13989
13990var getProfileMember = function() {
13991	$.getJSON('/template/checkLogin', function(data) {
13992		// if(!data.user) { }
13993		var imgstr = (data.myimg == 'https://storage.googleapis.com/i.addblock.net/member/profile_default.jpg') ? 'https://storage.googleapis.com/i.addblock.net/member/profile_default_top.png' : data.myimg;
13994		var str = 		'<span class="hexagon">\n';
13995			str = str + '	<svg viewBox="0 0 32 32">\n';
13996			str = str + '		<pattern id="pfimg-" + data.user +"" patternUnits="userSpaceOnUse" width="32" height="32">\n';
13997			str = str + '			<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href=""+imgstr+"" x="-2px" y="-2px" width="36" height="36"></image>\n';
13998			str = str + '		</pattern>\n';
13999			str = str + '		<polygon points="16 0 30 8 30 24 16 32 2 24 2 8" fill="url(#pfimg-" + data.user +")"></polygon>\n';
14000			str = str + '	</svg>\n';
14001			str = str + '</span>\n';
14002		$('.data-user .profile-img').append(str);
14003		$('.data-user .profile-img').addClass('user-'+data.name);
14004		$('.data-user .user-name').append('<span>'+data.name+'</span>');
14005		// $('.data-user .logoutlink').before('<span>You&apos;re logged in as '+data.name+' </span>');
14006
14007		var str3_mysite = '';
14008		if($('.data-site ul li span.text').text() == data.sid) {
14009			$('.data-site').text('');
14010			var isNewmessage = (data.newCount == 0 ) ? false : true;
14011			var str2 = 		'<ul class="sub-menu pull-right">\n';
14012				str2 = str2 + '	<li class="newCount">\n';
14013				str2 = str2 + '		<a href="/message/lists"><i class="fa fa-envelope"></i>\n';
14014				if(isNewmessage) str2 = str2 + '<span class="badge">"+data.newCount+"</span>\n';
14015				str2 = str2 + '</a>\n';
14016				str2 = str2 + '	</li>\n';
14017				str2 = str2 + '</ul>\n';
14018			$(".data-user .message").append(str2);
14019		} else {
14020			str3_mysite = '		<div class="item"><a href="http://'+data.sid+'.creatorlink.net"><img src="https://storage.googleapis.com/i.addblock.net/main/icon_mysite.png"/><img src="https://storage.googleapis.com/i.addblock.net/main/icon_mysite_active.png" class="active"/>'+ $.lang[LANG]['header.mysite'] + '</a></div>\n';
14021		}
14022
14023		var str3 = 		'<div class="popover bottom" id="pop"+data.name+"">\n';
14024			str3 = str3 + '	<div class="arrow"></div>\n';
14025			str3 = str3 + '	<div class="popover-content">\n';
14026			str3 = str3 + '		<div class="user-name">"+data.name+"</div>\n';
14027			str3 = str3 + str3_mysite;
14028			str3 = str3 + '		<div class="item"><a href="http://creatorlink.net"><img src="https://storage.googleapis.com/i.addblock.net/main/icon_dashboard.png"/><img src="https://storage.googleapis.com/i.addblock.net/main/icon_dashboard_active.png" class="active"/>'+ $.lang[LANG]['header.dashboard'] + '</a></div>\n';
14029			str3 = str3 + '		<div class="item"><a href="/mypage" ><img src="https://storage.googleapis.com/i.addblock.net/main/icon_acc.png"/><img src="https://storage.googleapis.com/i.addblock.net/main/icon_acc_active.png" class="active"/>'+ $.lang[LANG]['header.mypage'] +'</a></div>\n';
14030			str3 = str3 + '		<div class="item"><a href="/profile/myboard" ><img src="https://storage.googleapis.com/i.addblock.net/main/icon_qna.png"/><img src="https://storage.googleapis.com/i.addblock.net/main/icon_qna_active.png" class="active"/>'+ $.lang[LANG]['header.cts'] +'</a></div>\n';
14031			str3 = str3 + '		<div class="item user-logout"><a href="/member/login/out" class="logoutlink"><img src="https://storage.googleapis.com/i.addblock.net/main/icon_logout.png"/><img src="https://storage.googleapis.com/i.addblock.net/main/icon_logout_active.png" class="active"/>'+ $.lang[LANG]['header.logout'] + '</a></div>\n';
14032			str3 = str3 + '	</div>\n';
14033			str3 = str3 + '	</div>\n';
14034		$('.creatorlink-header').after(str3);
14035
14036	});
14037}
14038
14039var pageHeight = function() {
14040    $('.page-comments').css('margin-top','0px');
14041    $('.el-footer').css('margin-top','0px');
14042    var docHeight = $('.dsgn-body').height();
14043    $('.dsgn-body').wrapInner('<div class="dsgn-body-wrap"></div>');
14044    var dsgnHeight = $('.dsgn-body-wrap').height();
14045    var diff = docHeight - dsgnHeight;
14046    $('.dsgn-body > .dsgn-body-wrap').contents().unwrap();
14047    return (diff>0) ? diff : 0;
14048}
14049
14050var setHeight = function(height) {
14051	if(typeof property.VIEW == 'undefined' || property.VIEW == "") return false;
14052    if(height>0) {
14053        height = (typeof MODE == 'undefined') ? height : height-35;
14054        if($('.page-comments').length) {
14055            $('.page-comments').css('margin-top',height+'px');
14056		} else if($('.page-bottomlist').length) {
14057			$('.page-bottomlist').css('margin-top',height+'px');
14058        } else if($('.el-footer').length) {
14059            $('.el-footer').css('margin-top',height+'px');
14060        }
14061    }
14062}
14063
14064var makeLinkUrl = function(link, one, view) {
14065	var link_url = '',
14066		link_val = '',
14067		link_page = normalizeRenderMenuLinkPage(link),
14068		is_menu = ($.inArray(link_page, property.MENULIST) > -1) ? true : false,
14069		regex = /^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/,
14070		regex2 = /^((http(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,7}(\:[0-9]+)?(\/\S[^\{\}]*)?$/;
14071
14072	if (one) {
14073    	link_url = (view) ? '/#' : '#';
14074    	link_url = (view && !property.PUBLISH) ? '/render/index#' : link_url;
14075    	if(is_menu) link_url = '/';
14076	} else {
14077        link_url = (property.PUBLISH || is_menu) ? '/' : '/render/';
14078	}
14079
14080	if (link) {
14081		if (/^[^@]+@[0-9]+$/.test(link) && !/^flink@/i.test(link)) return link_url + link;
14082		if (link.match(/^\@/g) !== null) { // link-type: link-bookmark ==> a[attr-bookmark]
14083			var bookmark_seq = link.replace(/^\@/g, '');
14084			if (typeof property.SETTINGS.blockBookmarkList == 'undefined' || typeof property.SETTINGS.blockBookmarkList['bookmark' + bookmark_seq] == 'undefined') {
14085				return '';
14086			}
14087		} else if (link.match(/^flink\@[0-9]/gi) !== null) { // link-type: link-file     ==> a[attr-flink]
14088			return link;
14089		} else if ($.inArray(link_page, property.MENULIST) > -1) { // link-type: link-menu     ==> a[data-user-link]
14090			link_val = link_url + link_page;
14091		} else { // link-type: link-out      ==> a[attr-link]
14092			if(checkBase64Encode(decodeURIComponent(link))) link = Base64.decode(decodeURIComponent(link));
14093			else if (checkBase64Encode(link)) link = Base64.decode(link);
14094
14095			if(!regex2.test(link) && regex.test(link)) link_val = '//' + link;
14096		}
14097
14098		if(link_val == '') link_val = link;
14099	}
14100	return link_val;
14101}
14102
14103var checkError = function(data) {
14104    if(typeof data.error != 'undefined' && data.error) {
14105        alert(data.error);
14106        if(data.error=='No user data') {
14107            location.href='/member/login';
14108        }
14109        return true;
14110    }
14111    return false;
14112}
14113
14114var funcCallback = function(func,callback) {
14115    func();
14116    if(typeof callback=='function') {
14117        callback();
14118    }
14119}
14120
14121var closeClnavMega = function() {
14122	if(typeof $.clnav == 'undefined') return;
14123	if($('.cl-nav[data-layout="meganav"]').length == 0) return;
14124	if(!$('body').is('[data-clnav-mega="open"]')) return;
14125
14126	$.clnav.setMode('mega-open', false);
14127}
14128
14129var cssSidebar = function(onoff) {
14130	var width = (onoff == 'on') ? '260px' : '',
14131		dsgn_css = CSSJSON.toJSON($('#dsgn-body').text());
14132
14133	if(width) {
14134		if(typeof dsgn_css['children']['.dsgn-body.sidebar'] == 'undefined') {
14135			dsgn_css['children']['.dsgn-body.sidebar'] = {'children' : {}, 'attributes' : { 'padding-left' : width, 'padding-top': '0px' }};
14136		}
14137	} else {
14138		if(typeof dsgn_css['children']['.dsgn-body.sidebar'] != 'undefined') {
14139			delete dsgn_css['children']['.dsgn-body.sidebar'];
14140		}
14141	}
14142
14143	$('#dsgn-body').text(CSSJSON.toCSS(dsgn_css));
14144}
14145
14146var getScreen = function() {
14147    var wid = window.innerWidth;
14148
14149    var screen_size = 0;
14150    if (0 < wid && wid < 480) {
14151        screen_size = 320;
14152    } else if(wid <= 480 && wid <768) {
14153        screen_size = 480;
14154    } else if (768 <= wid && wid < 992) {
14155        screen_size = 768;
14156    } else if (992 <= wid && wid < 1200 ) {
14157        screen_size = 992;
14158    } else if (wid >= 1200) {
14159        screen_size = 1200;
14160    }
14161
14162    return screen_size;
14163}
14164
14165var getScreenIndex = function() {
14166    var idx = 0;
14167    switch(SCREEN) {
14168        case 320:
14169        case 480:
14170            idx = 2;
14171            break;
14172        case 769:
14173            idx = 1;
14174            break;
14175
14176        case 992:
14177        case 1200:
14178            idx = 0;
14179            break;
14180
14181        default : idx = 0; break;
14182    }
14183    return idx;
14184}
14185var setGalleryReturnItemCookie = function(parent) {
14186	if(typeof parent == 'undefined' || !parent) return;
14187	var mode = (typeof parent.mode != 'undefined') ? parent.mode : '',
14188		seq = (typeof parent.seq != 'undefined') ? parent.seq : '',
14189		page = (typeof parent.page != 'undefined') ? parent.page : '',
14190		pid = (typeof parent.pid != 'undefined') ? parent.pid : '';
14191
14192	if (typeof property != 'undefined' && property.ONE && typeof parent.opage != 'undefined' && parent.opage) page = parent.opage;
14193	if (!page && typeof parent.ppage != 'undefined') page = parent.ppage;
14194
14195	if($.inArray(mode, ['project', 'shopping']) == -1 || !seq) return;
14196	$.cookie('gallery-item', seq, { path: '/', expires: 12 * 60 * 60 * 1000 });
14197	$.cookie('gallery-return-page', page, { path: '/', expires: 12 * 60 * 60 * 1000 });
14198	$.cookie('gallery-return-block', pid, { path: '/', expires: 12 * 60 * 60 * 1000 });
14199	$.cookie('gallery-return-item', seq, { path: '/', expires: 12 * 60 * 60 * 1000 });
14200}
14201
14202var galleryReturnRestorePending = false;
14203
14204var clearGalleryReturnTarget = function(clearGalleryState) {
14205	galleryReturnRestorePending = false;
14206	if (clearGalleryState) {
14207		$.removeCookie('gallery', { path: '/' });
14208		$.removeCookie('gallery-item', { path: '/' });
14209	}
14210	$.removeCookie('gallery-return-page', { path: '/' });
14211	$.removeCookie('gallery-return-block', { path: '/' });
14212	$.removeCookie('gallery-return-item', { path: '/' });
14213};
14214
14215var activateGalleryReturnTab = function(page) {
14216	if (!(typeof property != 'undefined' && property.ONE) || !page) return true;
14217	if (!window.clTabmenu) return false;
14218	var $button = $('.dsgn-body .cl-tabmenu .tabmenu-btn[data-page], .tabmenu-sticky-rail .cl-tabmenu .tabmenu-btn[data-page]').filter(function() {
14219		return String($(this).attr('data-page') || '') == String(page);
14220	}).first();
14221	if (!$button.length) return null;
14222
14223	var $tabmenu = $button.closest('.cl-tabmenu');
14224	var parentMenuUid = $tabmenu.attr('data-parent-menu-uid') || '';
14225	if (typeof window.clTabmenu.activateOnepageNavigationPage == 'function'
14226		&& window.clTabmenu.activateOnepageNavigationPage(page, parentMenuUid)) {
14227		return true;
14228	}
14229	if (($tabmenu.attr('data-tabmenu-mode') || 'page') == 'section' && typeof window.clTabmenu.activateSectionPage == 'function') {
14230		return window.clTabmenu.activateSectionPage(page, parentMenuUid);
14231	} else if (typeof window.clTabmenu.activateOnepagePage == 'function') {
14232		return window.clTabmenu.activateOnepagePage(page, parentMenuUid);
14233	}
14234	return false;
14235};
14236
14237var restoreGalleryReturnTarget = function(attempt) {
14238	attempt = attempt || 0;
14239	if (attempt == 0 && galleryReturnRestorePending) return false;
14240	galleryReturnRestorePending = true;
14241	var page = $.cookie('gallery-return-page') || '';
14242	var galleryId = $.cookie('gallery-return-block') || '';
14243	var itemId = $.cookie('gallery-return-item') || '';
14244	if (!page && !galleryId && !itemId) {
14245		galleryReturnRestorePending = false;
14246		return false;
14247	}
14248
14249	var tabActivated = activateGalleryReturnTab(page);
14250	var $gallery = galleryId ? $('.element[data-id="' + galleryId + '"]') : $();
14251	var $item = itemId ? $('.gallery-item[data-seq="' + itemId + '"]') : $();
14252	var canRestore = tabActivated === true || (tabActivated === null && $gallery.length && $gallery.is(':visible'));
14253	if (canRestore && $item.length) {
14254		var preserveGalleryState = $item.closest('.element[data-type="gallery"]').is('[data-gjs]');
14255		moveGallery(itemId);
14256		clearGalleryReturnTarget(!preserveGalleryState);
14257		return true;
14258	}
14259	if (canRestore && !itemId && $gallery.length) {
14260		scrollToBlock($gallery.first(), 1000);
14261		clearGalleryReturnTarget(true);
14262		return true;
14263	}
14264	if (attempt < 40) {
14265		setTimeout(function() { restoreGalleryReturnTarget(attempt + 1); }, 150);
14266	} else {
14267		if ($gallery.length) scrollToBlock($gallery.first(), 1000);
14268		clearGalleryReturnTarget(true);
14269	}
14270	return false;
14271};
14272var moveGallery = function(element) {
14273	activateGalleryReturnTab($.cookie('gallery-return-page') || '');
14274    var $item = $(`.gallery-item[data-seq="${element}"]`);
14275    if ($item.length == 0) {
14276		if($(`.element[data-id="${element}"]`).length > 0) $item = $(`.element[data-id="${element}"]`);
14277    	else return;
14278    }
14279
14280	if($.clnav.check()) {
14281		goToElement($item);
14282	} else {
14283		var header_fixed = $('header.navbar').height();
14284		var offset = ($('.dsgn-body').hasClass('sidebar')) ? 0 : -header_fixed;
14285		if($('header.navbar').hasClass('disableOffset') && !$item.hasClass('el_0')) offset = 0;
14286
14287		if (property.SID != 'undefined' && property.SID == 'kdomeshelter'){
14288			offset -= 300;
14289		}
14290
14291		var sTop = $item.offset().top + offset;
14292		$('html, body').animate({scrollTop: sTop}, 500, 'easeInOutQuart');
14293
14294		$.removeCookie('gallery', { path: '/' });
14295		$.removeCookie('gallery-item', { path : '/' });
14296	}
14297}
14298
14299var scrollToBlock = function(el, duration) {
14300	if(typeof duration == 'undefined') duration = 1200;
14301	if(typeof el == 'undefined' || !el || $(el).length == 0) return;
14302
14303	if($.clnav.check()) {
14304		goToElement(el);
14305	} else {
14306		var header_fixed = $('header.navbar').outerHeight();
14307		var offset = $('.dsgn-body').scrollTop();
14308		if(!$('.dsgn-body').hasClass('sidebar') && !$('header.navbar').hasClass('disableOffset')) offset -= header_fixed;
14309		var sTop = $(el).offset().top + offset;
14310		$('html, body').animate({ scrollTop: sTop }, duration, 'easeInOutQuart');
14311	}
14312}
14313
14314var clearDsgnbody = function() {
14315	closeClnavMega();
14316
14317	const removeSelectors = [
14318		'style[id^="el_"]:not([id*=el__]):not([data-tabmenu-page-preserve])',
14319		'script[id^="js_"]:not([id*=el__])',
14320		'.element[data-id="all_products"]',
14321		'.psearch-view',
14322		'.menu-lock-block',
14323		'.site-lock-block',
14324		'.config-image-view',
14325		'.forum-view',
14326		'.page-toolbars',
14327		'.page-comments',
14328		'.page-bottomlist',
14329	].join(',');
14330	$(removeSelectors).remove();
14331	$('.el-footer').hide();
14332
14333	var element = $('.dsgn-body .element[class*="el_"]:not([class*=el__]):not(.el-footer)');
14334	element.each(function() {
14335		const $el = $(this);
14336		const $parentElem = $el.closest('.elem');
14337		if($el.is('[data-tabmenu-page-preserve]') || $parentElem.is('[data-tabmenu-page-preserve]')) return true;
14338
14339		if($parentElem.length) {
14340			$parentElem.remove();
14341		} else {
14342			$el.remove();
14343		}
14344	});
14345}
14346
14347var ensureGalleryResponsiveImageClass = function($scope) {
14348	$scope.find('img').each(function() {
14349		var removeAttrs = [];
14350		if(this.attributes) {
14351			$.each(this.attributes, function(i, attr) {
14352				if(attr && attr.name !== 'class' && attr.name.indexOf('img-responsive') > -1) removeAttrs.push(attr.name);
14353			});
14354		}
14355		for(var i = 0; i < removeAttrs.length; i++) this.removeAttribute(removeAttrs[i]);
14356		$(this).addClass('img-responsive');
14357	});
14358}
14359
14360var golink = function(_this,link) {
14361	var wloc = window.location,
14362		local_link = (wloc.hostname == link.hostname) ? true : false,
14363		local_arr = ['/_register', '/_login'];
14364
14365	if(local_link && $.inArray(link.pathname,local_arr) == -1) {
14366    	var loc = link.pathname,
14367    		uri = (_this.b.PUBLISH) ? loc : loc.replace('/render/','');
14368
14369    	if((uri == '/render' || uri == '/') && !_this.b.ONE) {
14370			uri = '';
14371			$.each(_this.b.SMENU,function(i,v) {
14372				var menu_name = getRenderMenuPage(v);
14373				var checkMenuName = (uri == menu_name) ? true : false,
14374					checkMenuLink = (typeof v.link != 'undefined' && v.link) ? true : false;
14375
14376    			if(checkMenuName && checkMenuLink) {
14377    				uri = (v.link).replace(' ','-');
14378    			}
14379    		});
14380    		
14381    	}
14382
14383    	var go = (_this.b.PUBLISH) ? '/' + uri + link.hash: '/render/' + uri + link.hash;
14384		// 명품 쇼핑 검색 파라미터 처리
14385		if((link.search).length) go = go + link.search;
14386		_this.history.pushState(null,_this.b.TITLE,go);
14387
14388		if(typeof $.cookie('forum-item') != 'undefined') {
14389			// console.log('fm_view', $.cookie('forum_content_view'));
14390			setTimeout(function() {
14391	    		if(typeof $.cookie('forum_content_view') != 'undefined'){
14392                    var fm_view = $.cookie('forum_content_view');
14393                    var fv = (fm_view !== undefined && fm_view)? fm_view.split('&'):array();
14394                    var pid = (fv)? fv[0]:'';
14395                    var row_id = (fv)? fv[1]:'';
14396
14397                    scrollToBlock('.element[data-id="' + $.cookie('forum-item') + '"] .tpl-forum-list-title[data-id="'+row_id+'"]', 1000);
14398	    			$.removeCookie('forum-item', { path : '/' });
14399
14400                    $('.element[data-id="' + pid + '"] .tpl-forum-list-title[data-id="'+row_id+'"]').click();
14401                    // $.removeCookie('forum_content_view', { path: '/', expires: 12 * 60 * 60 * 1000 });
14402                } else {
14403                	scrollToBlock('.element[data-id="' + $.cookie('forum-item') + '"]', 1000);
14404	    			$.removeCookie('forum-item', { path : '/' });
14405                }
14406			}, 300);
14407		}
14408	} else {
14409		location.href = link.href;
14410	}
14411}
14412
14413
14414function draw_floating() {
14415    var fl_section_html = '',
14416		fl_bottom_html = '',
14417		fl_circle_html = '',
14418		el_html = '',
14419		data = {};
14420 
14421    $.each($('.floating_item li'), function(fi, fv){
14422        var fl_class = $(this).find('.icon').attr('class'),
14423            cid = ($(this).find('a').attr('data-cid')) ? $(this).find('a').attr('data-cid') : '',
14424            fl_link = ($(this).find('a').attr('data-link')) ? $(this).find('a').attr('data-link') : '',
14425            type = ($(this).find('a').attr('data-type')) ? $(this).find('a').attr('data-type') : '',
14426            data = ($(this).find('a').attr('data-data')) ? $(this).find('a').attr('data-data') : '',
14427            name = ($(this).find('a').attr('data-name')) ? $(this).find('a').attr('data-name') : '',
14428            regexp = /[0-9]+/,
14429            fl_url = (type=='defaultPhone') ? 'tel:'+property.TEL_LINK : data;
14430
14431            if(type=='top') return true;
14432            fl_icon_num = (type=='defaultPhone') ? '' : `${regexp.exec(fl_class)}`;
14433			// fl_link = (type=='address' || type=='page_move' || type=='storefarm') ? fl_link : '';
14434			fl_url = (type=='defaultPhone') ? fl_url : fl_link;
14435			fl_url = (type=='link') ? data : fl_url;
14436			fl_url = (type=='email') ? 'mailto:'+data : fl_url;
14437			fl_url = (type=='reservation') ? data : fl_url;
14438			fl_url = (type=='page_move' && data=='홈') ? '/' : fl_url;
14439			fl_url = (type=='sms') ? 'tel:'+ data : fl_url;
14440			fl_url = (type=='defaultPhone2') ? 'tel:'+ data : fl_url;
14441			if(fl_url.includes('pf.kakao')) {
14442				fl_url = (fl_url.includes('http://pf.kakao') || fl_url.includes('https://pf.kakao')) ? fl_url : fl_url = 'https://' + fl_url;
14443			}
14444         
14445        fl_section_html += `
14446        <li class="" data-type="${type}" data-name="${name}" data-cid="${cid}" data-link="${fl_url}">
14447            <a class="btn btn_ic${fl_icon_num}" href="${fl_url}">
14448                <div class="in">${name}
14449                    <span class="ic theme_background"></span>
14450                </div>
14451            </a>
14452        </li>
14453        `;
14454        
14455		var floating_open_sid = ['hyundae09']; // modoo 모바일 플로팅메뉴 open요청
14456		if($.inArray(property.SID, floating_open_sid) > -1) {
14457			fl_icon_num = (type=='defaultPhone') ? '1' : fl_icon_num;
14458			fl_bottom_html += `
14459			<a class="link_item _button_navi" href="${fl_url}" data-type="${type}">
14460				<span class=" icon icon${fl_icon_num}"></span>
14461			</a>
14462			`;
14463			fl_circle_html += `
14464			<a class="link_item _button_navi _bizPhone float-navi-button" href="${fl_url}" data-type="${type}">
14465				<span class=" icon icon${fl_icon_num} theme_background"></span>
14466			</a>
14467			`;
14468
14469		} else {
14470			fl_icon_num = (type=='defaultPhone') ? '1' : fl_icon_num;
14471			fl_bottom_html += `
14472			<a class="link_item _button_navi" href="${fl_url}" data-type="${type}">
14473				<span class=" text _text">${name}</span><span class=" icon icon${fl_icon_num}"></span>
14474			</a>
14475			`;
14476			fl_circle_html += `
14477			<a class="link_item _button_navi _bizPhone float-navi-button mfl_hide" href="${fl_url}" data-type="${type}">
14478				<span class="text _text">${name}</span><span class=" icon icon${fl_icon_num} theme_background"></span>
14479			</a>
14480			`;
14481		}
14482
14483		// console.log(fl_url);
14484    });
14485
14486    el_html += `
14487        <div class="btn_wrap m_floating">
14488			<ul class="btn_list">
14489				${fl_section_html}
14490			</ul>
14491		</div>
14492    `;
14493
14494	data = {
14495		'fl_bottom_html' : fl_bottom_html,
14496		'fl_circle_html' : fl_circle_html,
14497		'el_html' : el_html
14498	}
14499
14500	// 메뉴 디자인 변경시 모두 퀵메뉴랑 기존 탑버튼 위치 겹치는 문제 발생하여 기존 크링 탑버튼 숨김처리
14501	if(!$('._floating').hasClass('hide') && $('.floating_item li').length > 0) {
14502		$('.goto-top').hide().addClass('hide').css('pointer-events','none');
14503		    
14504	}
14505	return data;
14506}
14507    
14508
14509function m_floating(fl_data) {
14510	if($.isEmptyObject(fl_data)) return false;
14511	var	settings = (typeof property.SETTINGS !='undefined' && property.SETTINGS) ? property.SETTINGS : {},
14512		settings_modoo = (typeof settings.modoo !='undefined' && settings.modoo) ? settings.modoo : {},
14513		settings_mfloating = (typeof settings_modoo.mfloating !='undefined' && settings_modoo.mfloating) ? settings_modoo.mfloating : '';
14514
14515	if(settings_mfloating!='' && settings_mfloating && $('ul.floating_item._floating.modoo').length>0 && !$('._floating').hasClass('hide')) {
14516		var modoo_fnav_html = (settings_mfloating=='bottom') ? `
14517			<div class="floating_area _floating_area modoo" data-mfltype="${settings_mfloating}">
14518				<div class="floating_item floating_bottom _float_buttons">
14519					${fl_data.fl_bottom_html}
14520					<button type="button" class="btn_top _top_btn" data-type="top">
14521						<span class="blind">TOP</span><span class="icon_top"></span>
14522					</button>
14523				</div>
14524			</div>		
14525		` : `
14526		<div class="floating_area _floating_area modoo" data-mfltype="${settings_mfloating}">
14527			<div class="dimmed _bg_dimmed"></div>
14528			<div class="floating_item _float_buttons">
14529				${fl_data.fl_circle_html}
14530				<button type="button" class="btn_menu _toggle_btn" style="-webkit-tap-highlight-color: transparent;">
14531					<span class="icon nicon_more4 _icon_area theme_background"></span>
14532				</button>
14533			</div>
14534		</div>`
14535		;
14536
14537
14538		var floating_open_sid = ['hyundae09']; // modoo 모바일 플로팅메뉴 open요청
14539		if($.inArray(property.SID, floating_open_sid) > -1) {
14540			modoo_fnav_html = `
14541				<div class="floating_area _floating_area modoo" data-mfltype="${settings_mfloating}">
14542					<div class="floating_item _float_buttons">
14543						${fl_data.fl_circle_html}
14544						<button type="button" class="btn_menu _toggle_btn" style="-webkit-tap-highlight-color: transparent;">
14545							<span class="icon nicon_more4 _icon_area theme_background"></span>
14546						</button>
14547					</div>
14548				</div>`;
14549		}
14550		//$('.dsgn-body.modoo').append(modoo_fnav_html); 기존 코드
14551		
14552		if ($('.dsgn-body.modoo').length > 0) {
14553			$('.dsgn-body.modoo').append(modoo_fnav_html);
14554		} else if (property?.SETTINGS?.modoo?.floating) { // 모두 사이트 메뉴 디자인 변경 시 dsgn-body에 modoo가 포함되지 않아 모바일에서 퀵메뉴 안 보이는 문제 해결
14555			$('.dsgn-body').append(modoo_fnav_html);
14556		} 
14557		
14558	}
14559	
14560}
14561
14562function isMenuLock(callback) {
14563	var deferred = $.Deferred();
14564    var is_lock_block = 'active', r;
14565    var display_target = (property.VIEW) ? '.cl-s-product-detail, .lux-product-block, .cl-s-product-review, .cl-s-product-qna, .page-comments, .page-bottomlist' : '';
14566
14567    // if(property.VALIDPLAN && property.ISLOCK == 'true') { 
14568    if(property.ISLOCK == 'true') {
14569		setRenderTabmenuLockPending(property.PAGE, true);
14570		r = $.post('/template/menuLockController/type/lock_check', {s: property.SMENU, sid: property.SID, page: property.PAGE, publish : property.PUBLISH}, function(data) {
14571			var lock_type = data.lock_type,
14572				lock_error_type = (typeof data.error_data != 'undefined' && data.error_data.type) ? '.' + data.error_data.type : '';
14573			
14574			if(!data.error && data.result) { 
14575				property.ISLOCK = 'false';
14576				setRenderTabmenuLockPending(property.PAGE, false);
14577			} else {
14578				if(property.PUBLISH && lock_type == 'umlevel' && $.inArray(lock_error_type, ['', '.unlikesite', '.creatorlink']) > -1) {
14579					var returnUrl = location.pathname + location.search + location.hash;
14580					location.href = '/_login?refer=' + encodeURIComponent(returnUrl);
14581					return false;
14582				}
14583				// var checkGotoURL = '';
14584				// if((property.SITEUM == '1' || property.SITEUM == '2') && lock_error_type == '') checkGotoURL = '/_login';
14585				// else if(property.SITEUM == '2'&&  $.inArray(lock_error_type,['.unlikesite','.creatorlink']) > -1) checkGotoURL = '/_register';
14586				// if(checkGotoURL) {
14587				// 	location.href = checkGotoURL;
14588				// 	return false;
14589				// }
14590
14591				var text = $.lang[LANG]['render.menu-lock.' + lock_type + '.text'];
14592				if (typeof data.menuLockMsg !== 'undefined' && data.menuLockMsg) {
14593					text = data.menuLockMsg;
14594				}
14595
14596				if (lock_type=='umlevel') {
14597					if(lock_error_type == '' && property.SITEUM == '1') lock_error_type = '.onlylogin';
14598
14599					text = $.lang[LANG]['render.menu-lock.' + lock_type + '.text' + lock_error_type ];
14600					if(lock_error_type == '.lowerlevel') text = text.replace(/\#/gi, data.error_data.umlevel);
14601				} else if (lock_type == 'grade') {
14602					if(lock_error_type == '.nonmember' || (lock_error_type == '' && property.SITEUM == '1')) {
14603						if(property.PAGE!='_login' && property.PAGE!='_register' && property.PAGE!='_forgot') {
14604							location.href='/_login';
14605							return false;
14606						}
14607						lock_error_type = '.onlylogin';
14608					}
14609
14610					text = $.lang[LANG]['render.menu-lock.' + lock_type + '.text' + lock_error_type ];
14611					if(typeof text == 'undefined') {
14612						text = $.lang[LANG]['render.menu-lock.umlevel.text' + lock_error_type] || $.lang[LANG]['render.menu-lock.umlevel.text.onlylogin'] || $.lang[LANG]['render.menu-lock.umlevel.text'];
14613					}
14614					if(lock_error_type == '.lowerlevel') text = text.replace(/\#/gi, data.error_data.grade);
14615				}
14616
14617				var str = '\
14618							<div class="menu-lock-block">\
14619								<div class="inner-box text-center">\
14620									<div class="form-inline" role="form">\
14621										<div class="text">\
14622											<p> ' + text + ' </p>\
14623										</div>';
14624					if(lock_type=='password') {
14625						str = str + '\
14626										<div class="form-group">\
14627											<input class="form-control" type="password" placeholder="password" data-lock-password=""/>\
14628											<label class="error-text"></label>\
14629										</div>\
14630										<div class="form-group">\
14631											<span class="btn" data-edit="true" data-selector=".btn" data-lock-submit="">'+$.lang[LANG]['render.lock.password.submit']+'</span>\
14632										</div>\
14633						';
14634					}
14635					str = str + '\
14636									</div>\
14637								</div>\
14638							</div>\
14639				';
14640				if($.clnav.check()) {
14641					$('.dsgn-body').prepend(htmlspecialchars_decode(str));
14642				} else {
14643					$('.header.el-menu').after(htmlspecialchars_decode(str));
14644				}
14645		        $('#page-loading-css').remove();
14646			}
14647		    if(typeof callback == 'function') {
14648		    	callback();
14649
14650		    	if(display_target) {
14651					setTimeout(function() {
14652				    	if(property.ISLOCK == 'true') $(display_target).addClass('hide');
14653				    	else $(display_target).removeClass('hide');
14654					},20);
14655		    	}
14656		    }
14657
14658    	},'json');
14659	} else {
14660		setRenderTabmenuLockPending(property.PAGE, false);
14661	    if(typeof callback == 'function') {
14662	    	callback();
14663			setTimeout(function() {
14664				$('.header.el-menu.hide').removeClass('hide');
14665				if(display_target) $(display_target).removeClass('hide');
14666			},20);
14667	    }
14668	}
14669
14670	deferred.resolve();
14671	return deferred.promise();
14672}
14673
14674function isSitePasswordLock() {
14675	var deferred = $.Deferred();
14676	let last_activity = localStorage.getItem("last_activity");
14677	let ss_site_lock = localStorage.getItem('ss_' + property.SID + '_site_lock');
14678    
14679    if (last_activity && ss_site_lock) {
14680    	let timeDiff = Math.floor(Date.now() / 1000) - Number(last_activity);
14681    	// console.log(Math.floor(Date.now() / 1000), Number(last_activity), timeDiff);
14682    	if (timeDiff > 3600) {
14683	    	// console.log('localStorage clear');
14684	        localStorage.removeItem('last_activity');
14685	        localStorage.removeItem('ss_' + property.SID + '_site_lock');
14686	        setTimeout(function(){
14687	        	location.href = '/';
14688	        });
14689	    }
14690    }
14691
14692	if(property.SETTINGS.sitePermit == undefined) {
14693		property.SETTINGS.sitePermit = 1;
14694	}
14695
14696	if(property.SETTINGS.sitePermit == 3) {
14697		let pw = (ss_site_lock)? ss_site_lock : '';
14698		r = $.post('/template/siteLockController/type/lock_check', {sid: property.SID, publish : property.PUBLISH, pw: pw}, function(data) {
14699			var lock_error_type = (typeof data.error_data != 'undefined' && data.error_data.type) ? '.' + data.error_data.type : '';
14700			if(!data.error && data.result) { 
14701				property.SETTINGS.sitePermit = 1;
14702			} else {
14703				var str = '\
14704					<div class="site-lock-block passwordonly">\
14705						<div class="inner-box text-center">\
14706							<div class="form-inline" role="form">\
14707								<div class="text">\
14708									<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="625 326 116 116" width="114" height="114"><path d="M700.5 379.5h-36v-12c0-9.92 8.08-18 18-18s18 8.08 18 18v12zm-34-2h32v-10c0-8.82-7.18-16-16-16s-16 7.18-16 16v10z"/><path d="M700.88 415.5h-36.75c-4.2 0-7.63-3.42-7.63-7.63v-22.75c0-4.2 3.42-7.63 7.63-7.63h1.38v2h-1.38c-3.1 0-5.63 2.52-5.63 5.63v22.75c0 3.1 2.52 5.63 5.63 5.63h36.75c3.1 0 5.63-2.52 5.63-5.63v-22.75c0-3.1-2.52-5.63-5.63-5.63h-1.38v-2h1.38c4.2 0 7.63 3.42 7.63 7.63v22.75c-.01 4.21-3.43 7.63-7.63 7.63z"/>
14708<path d="M665.5 377.5h34v2h-34z"/><path d="M683 442c-31.98 0-58-26.02-58-58s26.02-58 58-58 58 26.02 58 58-26.02 58-58 58zm0-114c-30.88 0-56 25.12-56 56s25.12 56 56 56 56-25.12 56-56-25.12-56-56-56z"/><circle cx="683" cy="393" r="4"/><path d="M683 403c-.55 0-1-.45-1-1v-9c0-.55.45-1 1-1s1 .45 1 1v9c0 .55-.45 1-1 1z"/></svg>';
14709						if(typeof data.sitelock_text != 'undefined' && data.sitelock_text) {
14710							str += '<p class="title">'+data.sitelock_text+'</p>';
14711						} else {
14712							str += '<p class="title">'+$.lang[LANG]['render.site-lock.password.text']+'</p>';
14713						}
14714						str += '</div>\
14715								<div class="form-group">\
14716									<div>\
14717										<input type="password" placeholder="'+$.lang[LANG]['render.site-lock.password.placeholder']+'" data-lock-password=""/>\
14718										<label class="error-text"></label>\
14719									</div>\
14720									<span class="btn" data-edit="true" data-selector=".btn" data-lock="site" data-lock-submit="">\
14721									<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="676 378.59 13 9.41" width="13" height="9"><path d="m681 388-5-5 1.41-1.41 3.59 3.58 6.59-6.58L689 380z"></path></svg>\
14722									</span>\
14723								</div>\
14724							</div>\
14725						</div>\
14726					</div>\
14727				';
14728				if($.clnav.check()) {
14729					$('.dsgn-body').prepend(htmlspecialchars_decode(str));
14730				} else {
14731					$('.header.el-menu').after(htmlspecialchars_decode(str));
14732				}
14733			}
14734			if(data.reload === true && data.result) {
14735				setTimeout(function(){
14736					location.reload();
14737				});
14738			}
14739		}, 'json');
14740	}
14741	
14742    deferred.resolve();
14743	return deferred.promise();
14744}
14745
14746function isUserCertified(history) {
14747	var referrer = (document.referrer !== undefined)? document.referrer.replace(/^https?:\/\//, ''):'';
14748	var seg = referrer.split('/');
14749
14750	if(property.CERT_USE == 'A' && property.VALIDTYPE != 'BN' && property.VALIDTYPE != 'SM') { //요금제 만료
14751		var str = '\
14752			<div class="site-lock-block">\
14753				<div class="inner-box text-center">\
14754					<div class="form-inline">\
14755						<div class="text">\
14756							<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 118 118" width="118" height="118"><path d="M76.88 52.5h-.38v-10c0-9.92-8.08-18-18-18s-18 8.08-18 18v10h-.38c-4.2 0-7.62 3.42-7.62 7.62v22.75c0 4.2 3.42 7.62 7.62 7.62h36.75c4.2 0 7.62-3.42 7.62-7.62V60.12c.01-4.2-3.41-7.62-7.61-7.62zm-34.38-10c0-8.82 7.18-16 16-16s16 7.18 16 16v10h-32v-10zm40 40.38c0 3.1-2.52 5.62-5.62 5.62H40.12c-3.1 0-5.62-2.52-5.62-5.62V60.12c0-3.1 2.52-5.62 5.62-5.62h36.76c3.1 0 5.62 2.52 5.62 5.62v22.76z"/><path d="M59 1C27.02 1 1 27.02 1 59s26.02 58 58 58 58-26.02 58-58S90.98 1 59 1zm0 114C28.12 115 3 89.88 3 59S28.12 3 59 3s56 25.12 56 56-25.12 56-56 56z"/><path d="M59 64c-2.21 0-4 1.79-4 4 0 1.86 1.28 3.41 3 3.86V77c0 .55.45 1 1 1s1-.45 1-1v-5.14c1.72-.45 3-2 3-3.86 0-2.21-1.79-4-4-4z"/></svg>\
14757							<p class="title">'+$.lang[LANG]['siteum.site.access.limit']+'</p>\
14758						</div>\
14759					</div>\
14760				</div>\
14761			</div>\
14762		';
14763
14764		if($.clnav.check()) {
14765			$('.dsgn-body').prepend(htmlspecialchars_decode(str));
14766		} else {
14767			$('.header.el-menu').after(htmlspecialchars_decode(str));
14768		}
14769		return false;
14770	}
14771
14772	r = $.post('/template/isUserCertified', {sid: property.SID, publish : property.PUBLISH}, function(data) {
14773		var cert_form = '';
14774
14775		// JH 주석2 : 문제 시 아래 주석
14776		if(property.CERT_USE == 'A' && typeof data.cert_adult != 'undefined' && data.cert_adult == 'N') {
14777			_this.b.certOpenChk = true;
14778		}
14779		
14780
14781		if((property.CERT_USE == 'Y' && data.cert != 'Y') || (property.CERT_USE == 'A' && data.cert_adult != 'Y')) {
14782			// V2: ordr_idxx는 서버(cert_req)에서 생성 — 프런트 init_orderid() 불필요
14783			cert_form = '\
14784				<form name="form_auth" method="post" action="/cert_req">\
14785			        <input type="hidden" name="param_opt_1" value="myinfo"/>\
14786			        <input type="hidden" name="param_opt_2" value="'+data.userid+'"/>\
14787				</form>\
14788				<form name="myinfo_form" method="post" action="/_myinfo_proc">\
14789				<input type="hidden" id="cert_data" name="cert_data" value="">\
14790					<input type="hidden" id="input-name" name="name" value="'+data.name+'">\
14791					<input type="hidden" id="input-birth" name="birth" value="'+data.birth+'">\
14792					<input type="hidden" id="input-tel" name="tel" value="'+data.tel+'">\
14793					<input type="hidden" id="input-gender" name="gender" value="'+data.gender+'">\
14794					<input type="hidden" id="input-email" name="email" value="'+data.email+'">\
14795					<input type="hidden" id="input-id" name="id" value="'+data.userid+'">\
14796				</form>\
14797			';
14798
14799			if(property.CERT_USE == 'Y'){
14800				if(property.SETTINGS.sitePermit == '2Y') {
14801					if(!data.userid){
14802						if(property.ONE && !property.VIEW) { //onepage site
14803							var onpage_seq = property.pageContent.index[0]['seq'];
14804							if(onpage_seq!='login' && onpage_seq!='register' && onpage_seq!='forgot'){
14805								location.href='/_login';
14806							}
14807						} else {
14808							if(property.PAGE!='_login' && property.PAGE!='_register' && property.PAGE!='_forgot') {
14809								location.href='/_login';
14810							}
14811						}
14812						
14813					} else {
14814						var str = '\
14815						<div class="site-lock-block useronly">\
14816							<div class="inner-box text-center">\
14817								<div class="form-inline">\
14818									<div class="text">\
14819									'+cert_form+'\
14820										<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="120" height="120"><defs/><g><circle cx="-220.9" cy="60" r="24" class="cls-9"/></g><g/><g><circle cx="60" cy="24" r="22" style="fill:#dbdbdb;"/><path d="M54 52h12c16.56 0 30 13.44 30 30v12c0 4.42-3.58 8-8 8H32c-4.42 0-8-3.58-8-8V82c0-16.56 13.44-30 30-30Z" style="fill:#dbdbdb;"/><path d="m97.34 71.03 3.8 2.58c.67.46 1.43.77 2.23.92l4.51.86a5.95 5.95 0 0 1 4.73 4.73l.86 4.51c.15.8.47 1.56.92 2.23l2.58 3.8a5.942 5.942 0 0 1 0 6.68l-2.58 3.8c-.46.67-.77 1.43-.92 2.23l-.86 4.51a5.95 5.95 0 0 1-4.73 4.73l-4.51.86c-.8.15-1.56.47-2.23.92l-3.8 2.58a5.942 5.942 0 0 1-6.68 0l-3.8-2.58c-.67-.46-1.43-.77-2.23-.92l-4.51-.86a5.95 5.95 0 0 1-4.73-4.73l-.86-4.51c-.15-.8-.47-1.56-.92-2.23l-2.58-3.8a5.942 5.942 0 0 1 0-6.68l2.58-3.8c.46-.67.77-1.43.92-2.23l.86-4.51a5.95 5.95 0 0 1 4.73-4.73l4.51-.86c.8-.15 1.56-.47 2.23-.92l3.8-2.58a5.942 5.942 0 0 1 6.68 0Z" style="fill:#4D94FA"/><path d="M94 74c.39 0 .77.12 1.09.34l3.8 2.58c1.13.77 2.39 1.29 3.74 1.55l4.51.86c.79.15 1.39.76 1.54 1.54l.86 4.51c.26 1.35.78 2.6 1.55 3.74l2.58 3.8c.45.66.45 1.52 0 2.18l-2.58 3.8a9.941 9.941 0 0 0-1.55 3.74l-.86 4.51c-.15.79-.76 1.39-1.54 1.54l-4.51.86c-1.35.26-2.6.78-3.74 1.55l-3.8 2.58c-.32.22-.7.34-1.09.34s-.77-.12-1.09-.34l-3.8-2.58a9.941 9.941 0 0 0-3.74-1.55l-4.51-.86c-.79-.15-1.39-.76-1.54-1.54l-.86-4.51c-.26-1.35-.78-2.6-1.55-3.74l-2.58-3.8c-.45-.66-.45-1.52 0-2.18l2.58-3.8a9.941 9.941 0 0 0 1.55-3.74l.86-4.51c.15-.79.76-1.39 1.54-1.54l4.51-.86c1.35-.26 2.6-.78 3.74-1.55l3.8-2.58c.32-.22.7-.34 1.09-.34m0-4c-1.17 0-2.33.34-3.34 1.03l-3.8 2.58c-.67.46-1.43.77-2.23.92l-4.51.86a5.95 5.95 0 0 0-4.73 4.73l-.86 4.51c-.15.8-.47 1.56-.92 2.23l-2.58 3.8a5.942 5.942 0 0 0 0 6.68l2.58 3.8c.46.67.77 1.43.92 2.23l.86 4.51a5.95 5.95 0 0 0 4.73 4.73l4.51.86c.8.15 1.56.47 2.23.92l3.8 2.58c1.01.69 2.18 1.03 3.34 1.03s2.33-.34 3.34-1.03l3.8-2.58c.67-.46 1.43-.77 2.23-.92l4.51-.86a5.95 5.95 0 0 0 4.73-4.73l.86-4.51c.15-.8.47-1.56.92-2.23l2.58-3.8a5.942 5.942 0 0 0 0-6.68l-2.58-3.8c-.46-.67-.77-1.43-.92-2.23l-.86-4.51a5.95 5.95 0 0 0-4.73-4.73l-4.51-.86c-.8-.15-1.56-.47-2.23-.92l-3.8-2.58A5.919 5.919 0 0 0 94 70Z" style="fill: #4789e7;"/><path d="M91.59 101.71c-.51 0-1.02-.2-1.41-.59l-6.59-6.59c-.78-.78-.78-2.05 0-2.83s2.05-.78 2.83 0l5.17 5.17 10-10c.78-.78 2.05-.78 2.83 0s.78 2.05 0 2.83l-11.41 11.41c-.39.39-.9.59-1.41.59Z" style="fill:#fff"/></g></svg>\
14821										<p class="title">'+$.lang[LANG]['siteum.cert.user']+'</p>\
14822										'+$.lang[LANG]['siteum.cert.user.txt']+'\
14823										<button class="btn cl-s-btn cl-s-btn-full btn-cert" onclick="return auth_type_check(true);">\
14824										<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32">
14824<path d="M22 0H10C7.79 0 6 1.79 6 4v24c0 2.21 1.79 4 4 4h12c2.21 0 4-1.79 4-4V4c0-2.21-1.79-4-4-4zm2 28c0 1.1-.9 2-2 2H10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h12c1.1 0 2 .9 2 2v24z"/><path d="M18 4h-4c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>\
14825										'+$.lang[LANG]['siteum.cert.user.btn']+'</button>\
14826										<a class="btn cl-s-btn cl-s-btn-primary cl-s-btn-full logout" href="javascript:;">'+ $.lang[LANG]['siteum.cert.user.exit'] +'</a>\
14827									</div>\
14828								</div>\
14829							</div>\
14830						</div>\
14831						';
14832						if($.clnav.check()) {
14833							$('.dsgn-body').prepend(htmlspecialchars_decode(str));
14834						} else {
14835							$('.header.el-menu').after(htmlspecialchars_decode(str));
14836						}
14837
14838						$(document).on('click', '.btn.logout', function(e){
14839							e.preventDefault();
14840							$.getJSON('/umember/login/out', function(r) {
14841								if($.cookie('cert_popup') !== undefined) {
14842									$.removeCookie('cert_popup', true, { path: '/', expires: 12 * 60 * 60 * 1000 });
14843								}							
14844								location.reload();
14845							},'json');
14846						});
14847					}
14848				} else {
14849					if($.inArray(property.PAGE, ['_register', '_login', '_forgot', '_mypost', '_myinfo']) == -1) {
14850						var modal_content = '<p class="text-center">' + $.lang[LANG]['siteum.cert.identify.verification.txt.1'] + '</p>\
14851							<div class="info">\
14852							' + $.lang[LANG]['siteum.cert.identify.verification.txt.2'] + '\
14853							</div>';
14854
14855						if(data.cert == 'N') {
14856				        	modal_content += cert_form;
14857							$(this).showModalFlat($.lang[LANG]['siteum.cert.identify.verification'], modal_content, true, true, function() {
14858								auth_type_check(true);
14859							}, $.lang[LANG]['siteum.cert.identify.colse.btn'], $.lang[LANG]['siteum.cert.identify.verification.btn'],'modal-dialog cl-cmmodal cl-s-btn w560 cl-p70 cl-modal cl-close-btn user-not-cert-modal', false, function(){ //close
14860								$.getJSON('/umember/login/out', function(r) {
14861									location.href = r.url;
14862									// location.href = '/';
14863								},'json');
14864							}, '', function() { //hide
14865								$.getJSON('/umember/login/out', function(r) {
14866									location.href = r.url;
14867									// location.href = '/';
14868								},'json');
14869							});
14870						}
14871					}
14872				}
14873			} else if(property.CERT_USE == 'A') {
14874				if(!data.userid){
14875					if(property.ONE && !property.VIEW) { //onepage site
14876						var onpage_seq = property.pageContent.index[0]['seq'];
14877						if(onpage_seq!='login' && onpage_seq!='register' && onpage_seq!='forgot'){
14878							location.href='/_login';
14879						}
14880					} else {
14881						if(property.PAGE!='_login' && property.PAGE!='_register' && property.PAGE!='_forgot') {
14882							location.href='/_login';
14883						}
14884					}
14885					
14886				} else {
14887					var str = '\
14888					<div class="site-lock-block adultonly">\
14889						<div class="inner-box text-center">\
14890							<div class="form-inline">\
14891								<div class="text">\
14892								'+cert_form+'\
14893									<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="120" height="120"><path class="st54" d="M49.68 82.35h-4.82V41.79l-8 4.89v-4.76l8.57-5.52h4.25v45.95z"/><path class="st54" d="M80.58 44.77c.42 1.35.78 3.33 1.08 5.94.3 2.6.44 5.83.44 9.68 0 2.71-.18 5.34-.54 7.9-.36 2.56-.98 4.92-1.87 7.08-.97 2.24-2.34 4.04-4.09 5.4-1.76 1.35-3.99 2.03-6.7 2.03-1.86 0-3.54-.31-5.05-.92-1.5-.61-2.74-1.38-3.71-2.32a9.926 9.926 0 0 1-2.13-3.43c-.49-1.31-.73-2.52-.73-3.62h5.65c0 .51.1 1.2.29 2.06.19.87.52 1.6.98 2.19.46.59 1.11 1.1 1.94 1.52.83.42 1.79.63 2.89.63 1.48 0 2.78-.53 3.9-1.59s1.98-2.41 2.57-4.06c.59-1.65 1.03-3.37 1.3-5.17s.41-3.5.41-5.11v-2.41c-.85 1.23-1.9 2.22-3.17 2.98-1.61.97-3.28 1.46-5.01 1.46-2.12 0-3.9-.32-5.36-.95-1.46-.63-2.76-1.61-3.9-2.92-1.06-1.27-1.86-2.86-2.41-4.76s-.83-3.87-.83-5.9c0-1.99.29-3.92.86-5.81.57-1.88 1.39-3.48 2.44-4.79 1.14-1.27 2.55-2.21 4.22-2.83 1.67-.61 3.33-.92 4.98-.92 1.61 0 3.24.32 4.89.95s3.05 1.59 4.19 2.86c1.06 1.32 1.88 2.93 2.47 4.83zm-19.17 5.78c0 1.44.17 2.8.51 4.09.34 1.29.85 2.42 1.52 3.4.68.97 1.5 1.71 2.48 2.22.97.51 1.99.76 3.05.76 1.02 0 2.01-.25 2.98-.76.97-.51 1.82-1.25 2.54-2.22.63-.97 1.13-2.1 1.49-3.4.36-1.29.54-2.66.54-4.09 0-1.44-.18-2.8-.54-4.09-.36-1.29-.86-2.42-1.49-3.4a8.128 8.128 0 0 0-2.54-2.19c-.97-.53-1.97-.79-2.98-.79-1.06 0-2.07.26-3.05.79a7.51 7.51 0 0 0-2.48 2.19c-.68.97-1.19 2.11-1.52 3.4a15.97 15.97 0 0 0-.51 4.09z"/><path class="st54" d="M119 58h-9v-9h-4v9h-9v4h9v9h4v-9h9z"/><path d="M100.91 81C93.26 95.83 77.8 106 60 106c-25.36 0-46-20.64-46-46s20.64-46 46-46c17.8 0 33.26 10.17 40.91 25h4.47C97.44 21.88 80.11 10 60 10c-27.61 0-50 22.39-50 50s22.39 50 50 50c20.11 0 37.44-11.88 45.38-29h-4.47z" fill="#e00"/></svg>\
14894									<p class="title">'+$.lang[LANG]['siteum.cert.adult']+'</p>\
14895									'+$.lang[LANG]['siteum.cert.adult.txt']+'\
14896									<button class="btn cl-s-btn cl-s-btn-full btn-cert" onclick="return auth_type_check(true);">\
14897									<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32">
14897<path d="M22 0H10C7.79 0 6 1.79 6 4v24c0 2.21 1.79 4 4 4h12c2.21 0 4-1.79 4-4V4c0-2.21-1.79-4-4-4zm2 28c0 1.1-.9 2-2 2H10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h12c1.1 0 2 .9 2 2v24z"/><path d="M18 4h-4c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>\
14898									'+$.lang[LANG]['siteum.cert.adult.btn']+'</button>\
14899									<a class="btn cl-s-btn cl-s-btn-primary cl-s-btn-full logout" href="javascript:;">'+ $.lang[LANG]['manager.site-um.logout'] +'</a>\
14900								</div>\
14901							</div>\
14902						</div>\
14903					</div>\
14904					';
14905					if($.clnav.check()) {
14906						$('.dsgn-body').prepend(htmlspecialchars_decode(str));
14907					} else {
14908						$('.header.el-menu').after(htmlspecialchars_decode(str));
14909					}
14910
14911					$(document).on('click', '.btn.logout', function(e){
14912						e.preventDefault();
14913						$.getJSON('/umember/login/out', function(r) {
14914							if($.cookie('cert_popup') !== undefined) {
14915								$.removeCookie('cert_popup', true, { path: '/', expires: 12 * 60 * 60 * 1000 });
14916							}							
14917							location.reload();
14918						},'json');
14919					});
14920				}
14921	    	}
14922		}
14923	}, 'json');
14924}
14925
14926function call_auth_data(frm) {
14927	auth_data(frm);
14928}
14929
14930var fonts_ko = ["@Korean", "IBM Plex Sans KR", "KoPub Batang", "Black Han Sans", "Gmarket Sans", "Godo", "Kukdetopokki", "Nanum Gothic", "Nanum Gothic Coding", "Nanum Myeongjo", "Nanum Barun Gothic", "Nanum Pen Script", "Nanum Barun Pen", "Nanum Brush Script", "Nanum Square", "Nanum Square Round", "Daraehand", "Dohyeon", "Recipekorea", "Monsori", "Noto Sans KR", "Noto Serif CJK KR", "BB Tree Gothic","BB Tree Namu",  "BB Tree Hand", "Seoul Namsan", "Seoul Hangang", "Suit", "Spoqa Han Sans", "S CoreDream", "Yeonsung", "Oseong and HanEum", "Iropke Batang", "EASTARJET", "Jalnan", "Jeju Gothic", "Jeju Myeongjo", "Jeju Hallasan", "Jua", "Youth", "Pretendard", "Hangyule", "Hanna"],
14931    fonts_en = ["@English", "Abel", "Abril Fatface", "Alegreya", "Aliquam", "Archivo", "Belleza", "Cardo", "Chakra Petch", "Caveat", "Cookie", "Cutive Mono", "Dancing Script", "Dosis", "Fredoka One", "Great Vibes", "Ibarra Real Nova", "Inter", "Jost", "Krona One", "Lato", "League Spartan", "Libre Baskerville", "Lora", "Montserrat", "Muli", "Nixie One", "Noto Sans", "Open sans", "Oswald", "Parisienne", "Playball", "Playfair Display", "Poppins", "PT Sans", "PT Serif", "Questrial", "Quicksand", "Raleway", "Roboto", "Roboto Slab", "Space Mono", "Source Code Pro", "Staatliches", "Stalemate", "Titillium Web"],
14932    fonts_ja = ["@Japanese", "Hannari", "Hokkori", "IoEI", "JKG", "MS Gothic", "MS Mincho", "Noto Sans JP", "Noto Serif JP"],
14933    fonts_th = ["@Thai", "Cyclin", "Hai Heritage Pro", "HFF Thai Dye", "Owah Tagu Siam NF"],
14934    fonts_ar = ["@Arabic", "Aceh Darusalam", "Amiri", "ArabDances", "Boecklins Universe", "Catharsis Bedouin", "Himchuli", "Kanisah", "Satyajit"],
14935    fonts_cr = ["@Cyrillic", "20db", "Alpha Echo", "Anonymous Pro", "Arsenal", "Bebas Neue", "Bitter", "Charis SIL", "Fira Mono", "Lato CR"],
14936    fonts_he = ["@Hebrew", "Alef", "Ezra SIL", "MendelSiddurMW"],
14937    fonts_ch = ["@Chinese", "cwTeXHei", "cwTeXKai", "cwTeXMing", "cwTeXYen", "Noto Sans SC", "Noto Sans TC", "Noto Serif SC", "Noto Serif TC"],
14938    fonts_vi = ["@Vietnamese", "Han Nom Gothic"];
14939    FONTS = [];
14940
14941for(i=0; i<UFONTS.length; i++){
14942    var fonts = eval('fonts_'+UFONTS[i]);
14943    FONTS = arrayUnique(fonts.concat(FONTS));
14944}
14945
14946function galleryStartHover() {
14947    $(this).find('figure').addClass('hover');
14948};
14949function galleryCloseHover() {
14950    $(this).find('figure').removeClass('hover');
14951};
14952function galleryMovelink() {
14953	$(this).find('a').click();
14954};
14955
14956$(function () {
14957	$(document).on('click', '.modoo._floating_area[data-mfltype^="ci"] ._toggle_btn', function(){
14958		var navi_btn = $('.modoo._floating_area[data-mfltype^="ci"]').find('.float-navi-button');
14959
14960		if(navi_btn.hasClass('mfl_hide')) {
14961			$('.modoo._floating_area[data-mfltype^="ci"]').removeClass('fl_open').addClass('fl_open');
14962			$('.modoo._floating_area[data-mfltype^="ci"]').find('.float-navi-button').removeClass('mfl_hide');
14963			$(this).removeClass('float-navi-open').addClass('float-navi-open');
14964			$(this).find('._icon_area').removeClass('nicon_more4').addClass('nicon_close');
14965		} else {
14966			$('.modoo._floating_area[data-mfltype^="ci"]').removeClass('fl_open');
14967			$('.modoo._floating_area[data-mfltype^="ci"]').find('.float-navi-button').addClass('mfl_hide');
14968			$(this).removeClass('float-navi-open');
14969			$(this).find('._icon_area').removeClass('nicon_close').addClass('nicon_more4');
14970		}
14971		
14972	});
14973
14974	$(document).on('click', '.nonePrice', function () {
14975		alert('로그인 후 이용이 가능합니다.');
14976		if (property['VALIDTYPE'] != 'SM') {
14977			$('.login .cl_icon_profile').click();
14978		} else {
14979			location.href='/_login';
14980		}
14981		return false;
14982	});
14983
14984	$(document).on('click', '.noneShoppingGrade, .noneShoppingGrade a', function(e) {
14985		e.preventDefault();
14986		e.stopImmediatePropagation();
14987		var msg = $(this).closest('.noneShoppingGrade').attr('data-shopping-grade-msg') || '해당 등급 고객 전용 상품입니다.';
14988		alert(normalizeShoppingGradeBlockedMessage(msg));
14989		return false;
14990	});
14991
14992});
14993
14994var naverLogCallback = function(callback) {
14995	if($('#naverLogload').length == 0) {
14996		var head= document.getElementsByTagName('head')[0];
14997		var script= document.createElement('script');
14998		script.type= 'text/javascript';
14999		script.id= 'naverLogload';
15000		script.src= '//wcs.naver.net/wcslog.js';
15001		script.addEventListener('load', callback);
15002		head.appendChild(script)
15003	} else {
15004		if(typeof callback == 'function') {
15005			callback();
15006		}
15007	}
15008}
15009
15010var member_only_item = function() {
15011	alert('로그인 후 이용이 가능합니다');
15012	location.href = "/_login";
15013}

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.