PageSourceSearch

https://rafflesinternationalcollege.ac.th/wp-content/cache/wpfc-minified/zhz0fno/61hdf.js

js rafflesinternationalcollege.ac.th collected 2026-10-08 10:02:35 UTC 141,064 bytes, 3,024 lines download raw bytes

1// source --> https://rafflesinternationalcollege.ac.th/wp-content/plugins/popup-builder/public/js/PopupBuilder.js?ver=4.4.5 
2function sgAddEvent(element, eventName, fn)
3{
4	if (element.addEventListener)
5		element.addEventListener(eventName, fn, false);
6	else if (element.attachEvent)
7		element.attachEvent('on' + eventName, fn);
8}
9/*Popup order count*/
10window.SGPB_ORDER = 0;
11
12function SGPBPopup()
13{
14	this.id = null;
15	this.eventName = '';
16	this.popupData = null;
17	this.additionalPopupData = {};
18	this.popupConfig = {};
19	this.popupObj = null;
20	this.onceListener();
21	this.initialsListeners();
22	this.countPopupOpen = true;
23	this.closeButtonDefaultPositions = {};
24	this.closeButtonDefaultPositions[1] = {
25		'left': 9,
26		'right': 9,
27		'bottom': 9
28	};
29	this.closeButtonDefaultPositions[2] = {
30		'left': 0,
31		'right': 0,
32		'top': parseInt('-20'),
33		'bottom': parseInt('-20')
34	};
35	this.closeButtonDefaultPositions[3] = {
36		'right': 4,
37		'bottom': 4,
38		'left': 4,
39		'top': 4
40	};
41	this.closeButtonDefaultPositions[4] = {
42		'left': 12,
43		'right': 12,
44		'bottom': 9
45	};
46	this.closeButtonDefaultPositions[5] = {
47		'left': 8,
48		'right': 8,
49		'bottom': 8
50	};
51	this.closeButtonDefaultPositions[6] = {
52		'left': parseInt('-18.5'),
53		'right': parseInt('-18.5'),
54		'bottom': parseInt('-18.5'),
55		'top': parseInt('-18.5')
56	};
57}
58
59SGPBPopup.htmlCustomButton = function()
60{
61	var buttons = jQuery('.sgpb-html-custom-button');
62	var buttonActionBehaviors = function(button, settings)
63	{
64		button.bind('click', function() {
65			var behavior = settings['sgpb-custom-button'];
66
67			if (behavior === 'redirectToURL') {
68				if (settings['sgpb-custom-button-redirect-new-tab']) {
69					window.open(settings['sgpb-custom-button-redirect-URL']);
70				}
71				else {
72					window.location.href = settings['sgpb-custom-button-redirect-URL'];
73				}
74			}
75			if (behavior === 'hidePopup') {
76				SGPBPopup.closePopup();
77			}
78			if (behavior === 'copyToClipBoard') {
79				var tempInputId = 1;
80				var value = settings['sgpb-custom-button-copy-to-clipboard-text'];
81				var tempInput = document.createElement("input");
82				tempInput.id = tempInputId;
83				tempInput.value = value;
84				tempInput.style = 'position: absolute; right: -10000px';
85				if (!document.getElementById(tempInputId)) {
86					document.body.appendChild(tempInput);
87				}
88				tempInput.select();
89				document.execCommand("copy");
90
91				if (settings['sgpb-copy-to-clipboard-close-popup']) {
92					SGPBPopup.closePopup();
93				}
94
95				if (settings['sgpb-custom-button-copy-to-clipboard-alert']) {
96					alert(settings['sgpb-custom-button-copy-to-clipboard-message']);
97				}
98			}
99		});
100	};
101
102	buttons.each(function() {
103		var settings = jQuery.parseJSON(decodeURIComponent(jQuery(this).attr('data-options')));
104		buttonActionBehaviors(jQuery(this), settings);
105	});
106};
107
108SGPBPopup.listeners = function () {
109	var that = this;
110
111	sgAddEvent(window, 'sgpbPopupBuilderAdditionalDimensionSettings', function(e) {
112		SGPBPopup.mobileSafariAdditionalSettings(e);
113	});
114
115	sgAddEvent(window, 'sgpbDidOpen', function(e) {
116		/*for mobile landscape issue*/
117		if (typeof (Event) === 'function') {
118			var event = new CustomEvent('resize', {
119				bubbles: true,
120				cancelable: true
121			});
122		}
123		else {
124			if (SGPBPopup.isIE()) {
125				var event = document.createEvent('Event');
126				event.initEvent('resize', true, true);
127			}
128			else {
129				var event = new CustomEvent('resize', {
130					bubbles: true,
131					cancelable: true
132				});
133			}
134		}
135		window.dispatchEvent(event);
136
137		SGPBPopup.mobileSafariAdditionalSettings(e);
138		var args = e.detail;
139		var popupOptions = args.popupData;
140
141		var obj = e.detail.currentObj.sgpbPopupObj;
142
143		/* if no analytics extension */
144		if (typeof SGPB_ANALYTICS_PARAMS === 'undefined') {
145			if (obj.getCountPopupOpen()) {
146				obj.addToCounter(popupOptions);
147			}
148		}
149
150		if (popupOptions['sgpb-show-popup-same-user']) {
151			obj.setPopupLimitationCookie(popupOptions);
152		}
153		SGPBPopup.htmlCustomButton();
154	});
155
156	setInterval(function() {
157		var openedPopups = window.sgpbOpenedPopup || {};
158		if (!Object.keys(openedPopups).length) {
159			return false;
160		}
161		var params = {};
162		params.popupsIdCollection = window.sgpbOpenedPopup;
163
164		var data = {
165			action: 'sgpb_send_to_open_counter',
166			nonce: SGPB_JS_PARAMS.nonce,
167			params: params
168		};
169
170
171		window.sgpbOpenedPopup = {};
172		jQuery.post(SGPB_JS_PARAMS.ajaxUrl, data, function(res) {
173
174		});
175	}, 600);
176};
177
178SGPBPopup.mobileSafariAdditionalSettings = function(e)
179{
180	if (typeof e === 'undefined') {
181		var args = SGPBPopup.prototype.getAdditionalPopupData();
182		if (typeof args === 'undefined') {
183			return false;
184		}
185		var popupOptions = args.popupData;
186		var popupId = parseInt(args.popupId);
187	}
188	else {
189		var args = e.detail;
190		var alreadySavedArgs = SGPBPopup.prototype.getAdditionalPopupData();
191		if (jQuery.isEmptyObject(alreadySavedArgs)) {
192			SGPBPopup.prototype.setAdditionalPopupData(args);
193		}
194		var popupOptions = args.popupData;
195		var popupId = parseInt(args.popupId);
196	}
197	var userAgent = window.navigator.userAgent;
198	if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
199		if (typeof popupOptions['sgpb-popup-dimension-mode'] !== 'undefined' && popupOptions['sgpb-popup-dimension-mode'] === 'responsiveMode') {
200			var openedPopupWidth = parseInt(window.innerHeight-100);
201			if (e.detail.popupData['sgpb-type'] === 'iframe' || e.detail.popupData['sgpb-type'] === 'video') {
202				if (jQuery('.sgpb-popup-builder-content-'+popupId +' iframe').length) {
203					jQuery('.sgpb-popup-builder-content-'+popupId).attr('style', 'height:'+openedPopupWidth+'px !important;');
204				}
205			}
206		}
207	}
208};
209
210SGPBPopup.prototype.setAdditionalPopupData = function(additionalPopupData)
211{
212	this.additionalPopupData = additionalPopupData;
213};
214
215SGPBPopup.prototype.getAdditionalPopupData = function()
216{
217	return this.additionalPopupData;
218};
219
220SGPBPopup.prototype.setCountPopupOpen = function(countPopupOpen)
221{
222	this.countPopupOpen = countPopupOpen;
223};
224
225SGPBPopup.prototype.getCountPopupOpen = function()
226{
227	return this.countPopupOpen;
228};
229
230SGPBPopup.playMusic = function(e) {
231	var args = e.detail;
232	var popupId = parseInt(args.popupId);
233	var options = SGPBPopup.getPopupOptionsById(popupId);
234	var soundUrl = options['sgpb-sound-url'];
235	var soundStatus = options['sgpb-open-sound'];	
236	if (soundStatus && soundUrl ) {
237		var audio = new Audio(soundUrl);		
238		audio.play();		
239		window.SGPB_SOUND[popupId] = audio;
240	}
241};
242
243SGPBPopup.floatingButton = function (e) {
244	SGPBPopup.showFloatingButton(e);
245
246	jQuery(window).on('sgpbFormSuccess', function (e){
247		SGPBPopup.hideFloatingButton();
248	});
249};
250
251SGPBPopup.showFloatingButton = function (e) {
252	var popupObj = e || {};
253	var popupId = 0;
254	var shouldShowFloatingButton = true;
255
256	/* if argument e is event reference the popup object is wrapped inside e.detail.currentObj.sgpbPopupObj  */
257	if (e.hasOwnProperty('sgpbPopupObj')) {
258		popupObj = e.detail.currentObj.sgpbPopupObj;
259	}
260
261	if (popupObj instanceof SGPBPopup) {
262		popupId = parseInt(popupObj.id);
263		shouldShowFloatingButton = popupObj.forceCheckCurrentPopupType(popupObj);
264	}
265
266	/* If there is no cookie which will prevent popup opening we will show floating button */
267	if (shouldShowFloatingButton) {
268		/* if we have popup id we detect exact button */
269		if (popupId) {
270			jQuery('.sgpb-floating-button.sg-popup-id-' + popupId).show();
271		} else {
272			jQuery('.sgpb-floating-button').show();
273		}
274	}
275};
276
277SGPBPopup.hideFloatingButton = function (popupId) {
278	/* if we have popup id we detect exact button */
279	if (popupId) {
280		jQuery('.sgpb-floating-button.sg-popup-id-' + popupId).fadeOut();
281	} else {
282		jQuery('.sgpb-floating-button').fadeOut();
283	}
284};
285
286SGPBPopup.prototype.initialsListeners = function()
287{
288	/* one time calling events (sgpbDidOpen, sgpbDidClose ...) */
289	var that = this;
290	sgAddEvent(window, 'sgpbDidOpen', function(e) {
291		jQuery('.sg-popup-close').unbind('click').bind('click',function(){
292			var currentPopupId = jQuery(this).parents('.sg-popup-builder-content').attr('data-id');
293			SGPBPopup.closePopupById(currentPopupId);
294		});
295	});
296
297	sgAddEvent(window, 'sgpbDidClose', function(e) {
298		var args = e.detail;
299		var popupId = parseInt(args.popupId);
300		that.htmlIframeFilterForOpen(popupId, 'close');
301	});
302};
303
304SGPBPopup.prototype.onceListener = function()
305{
306	var that = this;
307
308	sgAddEvent(window, 'sgpbDidOpen', function(e) {
309		document.onkeydown = function(e) {
310			e = e || window.event;
311
312			if (e.keyCode === 27) { /*esc pressed*/
313				var currentPopup = that.getPopupIdForNextEsc();
314				if (!currentPopup) {
315					return false;
316				}
317				var lastPopupId = parseInt(currentPopup['popupId']);
318				SGPBPopup.closePopupById(lastPopupId);
319			}
320		};
321	});
322
323	sgAddEvent(window, 'sgpbDidClose', function(e) {
324		if (window.sgPopupBuilder.length !== 0) {
325			var popups = [].concat(window.sgPopupBuilder).reverse();
326			for (var i in popups) {
327				var nextIndex = ++i;
328				var nextObj = popups[nextIndex];
329
330				if (typeof nextObj === 'undefined') {
331					jQuery('html').removeClass('sgpb-overflow-hidden');
332					jQuery('body').removeClass('sgpb-overflow-hidden-body');
333					break;
334				}
335
336				if (nextObj.isOpen === false) {
337					continue;
338				}
339				var options = SGPBPopup.getPopupOptionsById(nextObj.popupId);
340				if (typeof options['sgpb-disable-page-scrolling'] === 'undefined') {
341					jQuery('html').removeClass('sgpb-overflow-hidden');
342					jQuery('body').removeClass('sgpb-overflow-hidden-body');
343				}
344				else {
345					jQuery('html').addClass('sgpb-overflow-hidden');
346					jQuery('body').addClass('sgpb-overflow-hidden-body');
347				}
348				break;
349			}
350		}
351		else {
352			jQuery('html').addClass('sgpb-overflow-hidden');
353			jQuery('body').addClass('sgpb-overflow-hidden-body');
354		}
355	});
356};
357
358SGPBPopup.prototype.getPopupIdForNextEsc = function()
359{
360	var popups = window.sgPopupBuilder;
361	var popup = false;
362
363	if (!popups.length) {
364		return popup;
365	}
366
367	var searchPopups = [].concat(popups).reverse();
368
369	for (var i in searchPopups) {
370		var popupData = searchPopups[i];
371
372		if (popupData.isOpen) {
373			var popupId = parseInt(popupData['popupId']);
374			var popupOptions = SGPBPopup.getPopupOptionsById(popupId);
375
376			if (!popupOptions['sgpb-disable-popup-closing'] && popupOptions['sgpb-esc-key']) {
377				popup = popupData;
378				break;
379			}
380		}
381	}
382
383	return popup;
384};
385
386SGPBPopup.prototype.setPopupId = function(popupId)
387{
388	this.id = parseInt(popupId);
389};
390
391SGPBPopup.prototype.getPopupId = function()
392{
393	return this.id;
394};
395
396SGPBPopup.prototype.setPopupObj = function(popupObj)
397{
398	this.popupObj = popupObj;
399};
400
401SGPBPopup.prototype.getPopupObj = function()
402{
403	return this.popupObj;
404};
405
406SGPBPopup.prototype.setPopupData = function(popupData)
407{
408	if (typeof popupData == 'string') {
409		var popupData = SGPBPopup.JSONParse(popupData);
410	}
411
412	this.popupData = popupData;
413};
414
415SGPBPopup.prototype.getPopupData = function()
416{
417	return this.popupData;
418};
419
420SGPBPopup.prototype.setPopupConfig = function(config)
421{
422	this.popupConfig = config;
423};
424
425SGPBPopup.prototype.getPopupConfig = function()
426{
427	return this.popupConfig;
428};
429
430SGPBPopup.prototype.setUpPopupConfig = function()
431{
432	var popupConfig = new PopupConfig();
433	this.setPopupConfig(popupConfig);
434};
435
436SGPBPopup.createPopupObjById = function(popupId)
437{
438	var options = SGPBPopup.getPopupOptionsById(popupId);
439
440	if (!options) {
441		return false;
442	}
443	var popupObj = new SGPBPopup();
444	popupObj.setPopupId(popupId);
445	popupObj.setPopupData(options);
446
447	return popupObj;
448};
449
450
451SGPBPopup.getPopupOptionsById = function(popupId)
452{
453	var popupDataDiv = jQuery('#sg-popup-content-wrapper-'+popupId);
454
455	if (!popupDataDiv.length) {
456		return false;
457	}
458	var options = popupDataDiv.attr('data-options');
459
460	return SGPBPopup.JSONParse(options);
461};
462
463SGPBPopup.prototype.getCompatibleZiIndex = function(popupZIndex)
464{
465	/*2147483647 it's maximal z index value*/
466	if (popupZIndex > 2147483647) {
467		return 2147483627;
468	}
469
470	return popupZIndex;
471};
472
473SGPBPopup.prototype.prepareOpen = function()
474{
475	var popupId = this.getPopupId();
476	var popupData = this.getPopupData();
477	var popupZIndex = this.getCompatibleZiIndex(popupData['sgpb-popup-z-index']);
478	var popupType = this.popupData['sgpb-type'];
479	this.setUpPopupConfig();
480	var that = this;
481	var popupConfig = this.getPopupConfig();
482
483	function decodeEntities(encodedString)
484	{
485		if (typeof encodedString == 'undefined') {
486			return '';
487		}
488		var suspiciousStrings = ['document.createElement', 'createElement', 'String.fromCharCode', 'fromCharCode'];
489		for (var i in suspiciousStrings) {
490			if (encodedString.indexOf(suspiciousStrings[i]) > 0) {
491				return '';
492			}
493		}
494		var textArea = document.createElement('textarea');
495		textArea.innerHTML = encodedString;
496
497		return textArea.value;
498	}
499
500	popupConfig.customShouldOpen = function()
501	{
502		var instructions = popupData['sgpb-ShouldOpen'];
503		instructions = decodeEntities(instructions);
504		var F = new Function (instructions);
505
506		return(F());
507	};
508
509	popupConfig.customShouldClose = function()
510	{
511		var instructions = popupData['sgpb-ShouldClose'];
512		instructions = decodeEntities(instructions);
513		var F = new Function (instructions);
514
515		return(F());
516	};
517
518	this.setPopupDimensions();
519
520	if (popupData['sgpb-disable-popup-closing'] == 'on') {
521		popupData['sgpb-enable-close-button'] = '';
522		popupData['sgpb-esc-key'] = '';
523		popupData['sgpb-overlay-click'] = '';
524	}
525	/*used in the analytics*/
526	popupData['eventName'] = this.eventName;
527
528	if (SGPBPopup.varToBool(popupData['sgpb-enable-close-button'])) {
529		popupConfig.magicCall('setCloseButtonDelay', parseInt(popupData['sgpb-close-button-delay']));
530	}
531
532	popupConfig.magicCall('setShowButton', SGPBPopup.varToBool(popupData['sgpb-enable-close-button']));
533	/* Convert seconds to micro seconds */
534	var openAnimationSpeed = parseFloat(popupData['sgpb-open-animation-speed'])*1000;
535	var closeAnimationSpeed = parseFloat(popupData['sgpb-close-animation-speed'])*1000;
536	popupConfig.magicCall('setOpenAnimationEffect', popupData['sgpb-open-animation-effect']);
537	popupConfig.magicCall('setCloseAnimationEffect', popupData['sgpb-close-animation-effect']);
538	popupConfig.magicCall('setOpenAnimationSpeed', openAnimationSpeed);
539	popupConfig.magicCall('setCloseAnimationSpeed', closeAnimationSpeed);
540	popupConfig.magicCall('setOpenAnimationStatus', popupData['sgpb-open-animation']);
541	popupConfig.magicCall('setCloseAnimationStatus', popupData['sgpb-close-animation']);
542	popupConfig.magicCall('setContentPadding', popupData['sgpb-content-padding']);
543	if (typeof SgpbRecentSalesPopupType != 'undefined') {
544		if (popupType == SgpbRecentSalesPopupType) {
545			/* set max z index for recent sales popup */
546			popupZIndex = 2147483647;
547			popupConfig.magicCall('setCloseAnimationEffect', 'fade');
548			popupConfig.magicCall('setCloseAnimationSpeed', 1000);
549			popupConfig.magicCall('setCloseAnimationStatus', 'on');
550		}
551	}
552
553	popupConfig.magicCall('setZIndex', popupZIndex);
554	popupConfig.magicCall('setCloseButtonWidth', popupData['sgpb-button-image-width']);
555	popupConfig.magicCall('setCloseButtonHeight', popupData['sgpb-button-image-height']);
556	popupConfig.magicCall('setPopupId', popupId);
557	popupConfig.magicCall('setPopupData', popupData);
558	popupConfig.magicCall('setAllowed', !SGPBPopup.varToBool(popupData['sgpb-disable-popup-closing']));
559	if (popupData['sgpb-type'] == SGPB_POPUP_PARAMS.popupTypeAgeRestriction) {
560		popupConfig.magicCall('setAllowed', false);
561	}
562	popupConfig.magicCall('setEscShouldClose', SGPBPopup.varToBool(popupData['sgpb-esc-key']));
563	popupConfig.magicCall('setOverlayShouldClose', SGPBPopup.varToBool(popupData['sgpb-overlay-click']));
564
565	popupConfig.magicCall('setScrollingEnabled', SGPBPopup.varToBool(popupData['sgpb-enable-content-scrolling']));
566
567	if (SGPBPopup.varToBool(popupData['sgpb-content-click'])) {
568		this.contentCloseBehavior();
569	}
570	sgAddEvent(window, 'sgpbWillOpen', function(e) {
571		if (popupId != e.detail.popupId || e.detail.popupData['sgpb-content-click'] == 'undefined') {
572			return false;
573		}
574		/* triggering any popup content click (analytics) */
575		that.popupContentClick(e);
576	});
577	if (SGPBPopup.varToBool(popupData['sgpb-popup-fixed'])) {
578		this.addFixedPosition();
579	}
580	/*ThemeCreator*/
581	this.themeCreator();
582	this.themeCustomizations();
583
584	popupConfig.magicCall('setContents', document.getElementById('sg-popup-content-wrapper-'+popupId));
585	popupConfig.magicCall('setPopupType', popupType);
586	this.setPopupConfig(popupConfig);
587	this.popupTriggeringListeners();
588
589	/* check popup type, then check if popup can be opened by popup type */
590	var allowToOpen = this.checkCurrentPopupType();
591	if (allowToOpen) {
592		this.open();
593	}
594};
595
596SGPBPopup.prototype.popupContentClick = function(e)
597{
598	var args = e.detail;
599	var popupId = parseInt(args['popupId']);
600	jQuery('.sgpb-content-' + popupId).on('click', function(event) {
601		var settings = {
602			popupId: popupId,
603			eventName: 'sgpbPopupContentclick'
604		};
605		jQuery(window).trigger('sgpbPopupContentclick', settings);
606	});
607};
608
609SGPBPopup.prototype.forceCheckCurrentPopupType = function(popupObj)
610{
611	var allowToOpen = true;
612	var popupConfig = new PopupConfig();
613	var className = popupObj.popupData['sgpb-type'];
614	if (typeof className == 'undefined' || className == 'undefined') {
615		return false;
616	}
617
618	if (typeof SGPB_POPUP_PARAMS.conditionalJsClasses != 'undefined' && SGPB_POPUP_PARAMS.conditionalJsClasses.length) {
619		var isAllowConditions = this.forceIsAllowJsConditions(popupObj);
620
621		if (!isAllowConditions) {
622			return false;
623		}
624	}
625
626	var popupConfig = new PopupConfig();
627	var className = this.popupData['sgpb-type'];
628	/* make the first letter of a string uppercase, then concat prefix (uppercase all prefix string) */
629	className = popupConfig.prefix.toUpperCase() + PopupConfig.firstToUpperCase(className);
630	/* hasOwnProperty returns boolean value */
631	if (window.hasOwnProperty(className)) {
632		className = eval(className);
633		/* create current popup type object */
634		var obj = new className;
635		/* call allowToOpen function if exists */
636		if (typeof obj.allowToOpen === 'function') {
637			allowToOpen = obj.allowToOpen(this.id);
638			if (!allowToOpen) {
639				isAllow = allowToOpen;
640			}
641		}
642	}
643
644	var allowToOpen = this.checkCurrentPopupType();
645	if (!allowToOpen) {
646		return false;
647	}
648
649	return allowToOpen;
650};
651
652SGPBPopup.prototype.checkCurrentPopupType = function()
653{
654	var allowToOpen = true;
655	var popupConfig = new PopupConfig();
656
657	var isPreview = parseInt(this.popupData['sgpb-is-preview']);
658	if (!isNaN(isPreview) && isPreview == 1) {
659		return allowToOpen;
660	}
661
662	var popupHasLimit = this.isSatistfyForShowingLimitation(this.popupData);
663	if (!popupHasLimit) {
664		return false;
665	}
666
667	var dontShowPopupCookieName = 'sgDontShowPopup' + this.popupData['sgpb-post-id'];
668	var dontShowPopup = SGPopup.getCookie(dontShowPopupCookieName);
669	if (dontShowPopup != '') {
670		return false;
671	}
672
673	var className = this.popupData['sgpb-type'];
674	if (typeof className == 'undefined' || className == 'undefined') {
675		return false;
676	}
677
678	if (typeof SGPB_POPUP_PARAMS.conditionalJsClasses != 'undefined' && SGPB_POPUP_PARAMS.conditionalJsClasses.length) {
679		var isAllowConditions = this.isAllowJsConditions();
680
681		if (!isAllowConditions) {
682			return false;
683		}
684	}
685
686	/* make the first letter of a string uppercase, then concat prefix (uppercase all prefix string) */
687	className = popupConfig.prefix.toUpperCase() + PopupConfig.firstToUpperCase(className);
688	/* hasOwnProperty returns boolean value */
689	if (window.hasOwnProperty(className)) {
690		className = eval(className);
691		/* create current popup type object */
692		var obj = new className;
693		/* call allowToOpen function if exists */
694		if (typeof obj.allowToOpen === 'function') {
695			allowToOpen = obj.allowToOpen(this.id);
696		}
697	}
698
699	return allowToOpen;
700};
701
702SGPBPopup.prototype.forceIsAllowJsConditions = function(popupObj) {
703	var conditions = SGPB_POPUP_PARAMS.conditionalJsClasses;
704
705	var isAllow = true;
706
707	for (var i in conditions) {
708		if (!conditions.hasOwnProperty(i)) {
709			break;
710		}
711
712		try {
713			var className = eval(conditions[i]);
714		}
715		catch (e) {
716			continue;
717		}
718		var obj = new className;
719		/* call allowToOpen function if exists */
720		if (typeof obj.forceAllowToOpen === 'function') {
721			var popupData = this.getPopupData();
722			var allowToOpen = obj.forceAllowToOpen(popupObj.id, popupObj);
723
724			if (!allowToOpen) {
725				isAllow = allowToOpen;
726				break;
727			}
728		}
729	}
730
731	return isAllow;
732};
733
734SGPBPopup.prototype.isAllowJsConditions = function() {
735	var conditions = SGPB_POPUP_PARAMS.conditionalJsClasses;
736	var isAllow = true;
737
738	for (var i in conditions) {
739		if (!conditions.hasOwnProperty(i)) {
740			break;
741		}
742
743		try {
744			var className = eval(conditions[i]);
745		}
746		catch (e) {
747			continue;
748		}
749		var obj = new className;
750		/* call allowToOpen function if exists */
751		if (typeof obj.allowToOpen === 'function') {
752			var allowToOpen = obj.allowToOpen(this.id, this);
753			if (!allowToOpen) {
754				isAllow = allowToOpen;
755				break;
756			}
757		}
758	}
759
760	return isAllow;
761};
762
763SGPBPopup.prototype.setPopupLimitationCookie = function(popupData)
764{
765	var cookieData = this.getPopupShowLimitationCookie(popupData);
766	var cookie = cookieData.cookie || {};
767	var openingCount = cookie.openingCount || 0;
768	var currentUrl = window.location.href;
769
770	if (!popupData['sgpb-show-popup-same-user-page-level']) {
771		currentUrl = '';
772	}
773	cookie.openingCount = openingCount + 1;
774	cookie.openingPage = currentUrl;
775	var popupShowingLimitExpiry = parseInt(popupData['sgpb-show-popup-same-user-expiry']);
776
777	SGPBPopup.setCookie(cookieData.cookieName, JSON.stringify(cookie), popupShowingLimitExpiry, currentUrl);
778};
779
780SGPBPopup.prototype.isSatistfyForShowingLimitation = function(popupData)
781{
782	/*enable||disable*/
783	var popupLimitation = popupData['sgpb-show-popup-same-user'];
784
785	/*if this option unchecked popup must be show*/
786	if (!popupLimitation) {
787		return true;
788	}
789	var cookieData = this.getPopupShowLimitationCookie(popupData);
790
791	/*when there is not*/
792	if (!cookieData.cookie) {
793		return true;
794	}
795
796	return popupData['sgpb-show-popup-same-user-count'] > cookieData.cookie.openingCount;
797};
798
799SGPBPopup.prototype.getPopupShowLimitationCookie = function(popupData)
800{
801	var savedCookie = this.getPopupShowLimitationCookieDetails(popupData);
802	var savedCookie = this.filterPopupLimitationCookie(savedCookie);
803
804	return savedCookie;
805};
806
807SGPBPopup.prototype.filterPopupLimitationCookie = function(cookie)
808{
809	var result = {};
810	result.cookie = '';
811	if (cookie.isPageLevel) {
812
813		result.cookieName = cookie.pageLevelCookieName;
814		if (cookie.pageLevelCookie) {
815			result.cookie = jQuery.parseJSON(cookie.pageLevelCookie);
816		}
817
818		SGPBPopup.deleteCookie(cookie.domainLevelCookieName);
819
820		return result;
821	}
822	result.cookieName = cookie.domainLevelCookieName;
823	if (cookie.domainLevelCookie) {
824		result.cookie = jQuery.parseJSON(cookie.domainLevelCookie);
825	}
826	var currentUrl = window.location.href;
827
828	SGPBPopup.deleteCookie(cookie.pageLevelCookieName, currentUrl);
829
830	return result;
831};
832
833SGPBPopup.prototype.getPopupShowLimitationCookieDetails = function(popupData)
834{
835	var result = false;
836	var currentUrl = window.location.href;
837	var currentPopupId = popupData['sgpb-post-id'];
838
839	/*Cookie names*/
840	var popupLimitationCookieHomePageLevelName = 'SGPBShowingLimitationHomePage' + currentPopupId;
841	var popupLimitationCookiePageLevelName = 'SGPBShowingLimitationPage' + currentPopupId;
842	var popupLimitationCookieDomainName = 'SGPBShowingLimitationDomain' + currentPopupId;
843
844	var pageLevelCookie = popupData['sgpb-show-popup-same-user-page-level'] || false;
845
846	/*check if current url is home page*/
847	if (currentUrl == SGPB_POPUP_PARAMS.homePageUrl) {
848		popupLimitationCookiePageLevelName = popupLimitationCookieHomePageLevelName;
849	}
850	var popupLimitationPageLevelCookie = SGPopup.getCookie(popupLimitationCookiePageLevelName);
851	var popupLimitationDomainCookie = SGPopup.getCookie(popupLimitationCookieDomainName);
852
853	result = {
854		'pageLevelCookieName': popupLimitationCookiePageLevelName,
855		'domainLevelCookieName': popupLimitationCookieDomainName,
856		'pageLevelCookie': popupLimitationPageLevelCookie,
857		'domainLevelCookie': popupLimitationDomainCookie,
858		'isPageLevel': pageLevelCookie
859	};
860
861	return result;
862};
863
864SGPBPopup.prototype.themeCreator = function()
865{
866	var noPositionSelected = false;
867	var popupData = this.getPopupData();
868	var popupId = this.getPopupId();
869	var popupConfig = this.getPopupConfig();
870	var forceRtlClass = '';
871	var forceRtl = SGPBPopup.varToBool(popupData['sgpb-force-rtl']);
872	var popupTheme = popupData['sgpb-popup-themes'];
873	var popupType = popupData['sgpb-type'];
874	var closeButtonWidth = popupData['sgpb-button-image-width'];
875	var closeButtonHeight = popupData['sgpb-button-image-height'];
876	var contentPadding = parseInt(popupData['sgpb-content-padding']);
877	/* close button position */
878	var top = parseInt(popupData['sgpb-button-position-top']);
879	var right = parseInt(popupData['sgpb-button-position-right']);
880	var bottom = parseInt(popupData['sgpb-button-position-bottom']);
881	var left = parseInt(popupData['sgpb-button-position-left']);
882
883	var contentClass = popupData['sgpb-content-custom-class'];
884	/* for the 2-nd and 3-rd themes only */
885	var popupBorder = SGPBPopup.varToBool(popupData['sgpb-disable-border']);
886	var closeButtonImage = popupConfig.closeButtonImage;
887	var themeNumber = 1;
888	var backgroundColor = 'black';
889	var borderColor = 'inherit';
890	var recentSalesPopup = false;
891	if (typeof SgpbRecentSalesPopupType != 'undefined') {
892		if (popupType == SgpbRecentSalesPopupType) {
893			recentSalesPopup = true;
894			popupTheme = 'sgpb-theme-2';
895			closeButtonPosition = 'topRight';
896			backgroundColor = 'white';
897			borderColor = '#ececec';
898			top = '-10';
899			right = '-10';
900			popupConfig.magicCall('setShadowSpread', 1);
901			popupConfig.magicCall('setContentShadowBlur', 5);
902			popupConfig.magicCall('setOverlayVisible', false);
903			popupConfig.magicCall('setContentShadowColor', '#000000b3');
904			popupConfig.magicCall('setContentBorderRadius', '5px');
905		}
906	}
907	var themeIndexNum = popupTheme[popupTheme.length -1];
908
909	if (isNaN(top)) {
910		top = this.closeButtonDefaultPositions[themeIndexNum].top;
911	}
912	if (isNaN(right)) {
913		right = this.closeButtonDefaultPositions[themeIndexNum].right;
914	}
915	if (isNaN(bottom)) {
916		bottom = this.closeButtonDefaultPositions[themeIndexNum].bottom;
917	}
918	if (isNaN(left)) {
919		left = this.closeButtonDefaultPositions[themeIndexNum].left;
920	}
921	if (forceRtl) {
922		forceRtlClass = ' sgpb-popup-content-direction-right';
923	}
924	if (popupData['sgpb-type'] == 'countdown') {
925		popupConfig.magicCall('setMinWidth', 300);
926	}
927	popupConfig.magicCall('setContentPadding', contentPadding);
928	popupConfig.magicCall('setOverlayAddClass', popupTheme+'-overlay 
928sgpb-popup-overlay-' + popupId);
929	popupConfig.magicCall('setContentAddClass', 'sgpb-content sgpb-content-'+popupId+' ' + popupTheme+'-content ' + contentClass + forceRtlClass);
930
931	if (typeof popupData['sgpb-close-button-position'] == 'undefined' || popupData['sgpb-close-button-position'] == '') {
932		/*
933		 * in the old version we don't have close button position option
934		 * and if noPositionSelected is true, the popup was not edited
935		 */
936		var noPositionSelected = true;
937	}
938	else {
939		var closeButtonPosition = popupData['sgpb-close-button-position'];
940		popupConfig.magicCall('setButtonPosition', closeButtonPosition);
941	}
942
943	if (popupTheme == 'sgpb-theme-1') {
944		themeNumber = 1;
945		popupConfig.magicCall('setShadowSpread', 14);
946		/* 9px theme default close button position for all cases */
947		if (noPositionSelected || closeButtonPosition == 'bottomRight') {
948			popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
949			popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
950		}
951		else {
952			popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
953			popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
954		}
955	}
956	else if (popupTheme == 'sgpb-theme-2') {
957		themeNumber = 2;
958		popupConfig.magicCall('setButtonInside', false);
959		popupConfig.magicCall('setContentBorderWidth', 1);
960		popupConfig.magicCall('setContentBackgroundColor', backgroundColor);
961		popupConfig.magicCall('setContentBorderColor', borderColor);
962		popupConfig.magicCall('setOverlayColor', 'white');
963		var rightPosition = '0';
964		var topPosition = '-' + closeButtonHeight + 'px';
965		if (recentSalesPopup) {
966			rightPosition = '-' + (closeButtonWidth / 2) + 'px';
967			topPosition = '-' + (closeButtonHeight / 2) + 'px';
968			themeNumber = 6;
969		}
970		if (noPositionSelected || closeButtonPosition == 'topRight') {
971			/* this theme has 1px border */
972			popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
973			popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
974		}
975		else {
976			if (closeButtonPosition == 'topLeft') {
977				popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
978				popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
979			}
980			else if (closeButtonPosition == 'bottomRight') {
981				popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
982				popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
983			}
984			else if (closeButtonPosition == 'bottomLeft') {
985				popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
986				popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
987			}
988		}
989
990		if (popupBorder) {
991			popupConfig.magicCall('setContentBorderWidth', 0);
992		}
993	}
994	else if (popupTheme == 'sgpb-theme-3') {
995		themeNumber = 3;
996		popupConfig.magicCall('setContentBorderWidth', 5);
997		popupConfig.magicCall('setContentBorderRadius', popupData['sgpb-border-radius']);
998		popupConfig.magicCall('setContentBorderRadiusType', popupData['sgpb-border-radius-type']);
999		popupConfig.magicCall('setContentBorderColor', popupData['sgpb-border-color']);
1000		var closeButtonPositionPx = '4px';
1001		if (popupBorder) {
1002			popupConfig.magicCall('setContentBorderWidth', 0);
1003			closeButtonPositionPx = '0px';
1004		}
1005		if (noPositionSelected) {
1006			popupConfig.magicCall('setCloseButtonWidth', 38);
1007			popupConfig.magicCall('setCloseButtonHeight', 19);
1008			popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
1009			popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
1010		}
1011		else {
1012			if (closeButtonPosition == 'topRight') {
1013				popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
1014				popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
1015			}
1016			else if (closeButtonPosition == 'topLeft') {
1017				popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
1018				popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
1019			}
1020			else if (closeButtonPosition == 'bottomRight') {
1021				popupConfig.magicCall('setCloseButtonPositionLeft', right+'px');
1022				popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
1023			}
1024			else if (closeButtonPosition == 'bottomLeft') {
1025				popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
1026				popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
1027			}
1028		}
1029	}
1030	else if (popupTheme == 'sgpb-theme-4') {
1031		/* in theme-4 close button type is button,not image,
1032		 * then set type to button, default is image and
1033		 * set text
1034		 */
1035		themeNumber = 4;
1036		popupConfig.magicCall('setButtonImage', popupData['sgpb-button-text']);
1037		popupConfig.magicCall('setCloseButtonType', 'button');
1038		popupConfig.magicCall('setCloseButtonText', popupData['sgpb-button-text']);
1039		popupConfig.magicCall('setContentBorderWidth', 0);
1040		popupConfig.magicCall('setContentBackgroundColor', 'white');
1041		popupConfig.magicCall('setContentBorderColor', 'white');
1042		popupConfig.magicCall('setOverlayColor', 'white');
1043		popupConfig.magicCall('setShadowSpread', 4);
1044		popupConfig.magicCall('setContentShadowBlur', 8);
1045		/* 8px/12px theme default close button position for all cases */
1046		if (noPositionSelected || closeButtonPosition == 'bottomRight') {
1047			popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
1048			popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
1049		}
1050		else {
1051			popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
1052			popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
1053		}
1054	}
1055	else if (popupTheme == 'sgpb-theme-5') {
1056		themeNumber = 5;
1057		popupConfig.magicCall('setBoxBorderWidth', 10);
1058		popupConfig.magicCall('setContentBorderColor', '#4B4B4B');
1059		if (noPositionSelected || closeButtonPosition == 'bottomRight') {
1060			popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
1061			popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
1062		}
1063		else {
1064			popupConfig.magicCall('setCloseButtonPositionLeft', left+'px');
1065			popupConfig.magicCall('setCloseButtonPositionBottom', bottom+'px');
1066		}
1067	}
1068	else if (popupTheme == 'sgpb-theme-6') {
1069		themeNumber = 6;
1070		popupConfig.magicCall('setButtonInside', false);
1071		popupConfig.magicCall('setContentBorderRadius', 7);
1072		popupConfig.magicCall('setContentBorderRadiusType', 'px');
1073		if (noPositionSelected) {
1074			popupConfig.magicCall('setCloseButtonWidth', 37);
1075			popupConfig.magicCall('setCloseButtonHeight', 37);
1076			popupConfig.magicCall('setCloseButtonPositionRight', right+'px');
1077			popupConfig.magicCall('setCloseButtonPositionTop', top+'px');
1078		}
1079		else {
1080			if (typeof popupData['sgpb-button-position-right'] == 'undefined') {
1081				right = '-' + (closeButtonWidth / 2);
1082				top = '-' + (closeButtonHeight / 2);
1083				left = '-' + (closeButtonWidth / 2);
1084				bottom = '-' + (closeButtonHeight / 2);
1085			}
1086			if (closeButtonPosition == 'topRight') {
1087				popupConfig.magicCall('setCloseButtonPositionRight', right + 'px');
1088				popupConfig.magicCall('setCloseButtonPositionTop', top + 'px');
1089			}
1090			else if (closeButtonPosition == 'topLeft') {
1091				popupConfig.magicCall('setCloseButtonPositionLeft', left + 'px');
1092				popupConfig.magicCall('setCloseButtonPositionTop', top + 'px');
1093			}
1094			else if (closeButtonPosition == 'bottomRight') {
1095				popupConfig.magicCall('setCloseButtonPositionRight', right + 'px');
1096				popupConfig.magicCall('setCloseButtonPositionBottom', bottom + 'px');
1097			}
1098			else if (closeButtonPosition == 'bottomLeft') {
1099				popupConfig.magicCall('setCloseButtonPositionLeft', left + 'px');
1100				popupConfig.magicCall('setCloseButtonPositionBottom', bottom + 'px');
1101			}
1102		}
1103	}
1104
1105	popupConfig.magicCall('setPopupTheme', themeNumber);
1106	if (!popupData['sgpb-button-image']) {
1107		closeButtonImage = SGPB_POPUP_PARAMS.defaultThemeImages[themeNumber];
1108		if (typeof closeButtonImage  != 'undefined') {
1109			popupConfig.magicCall('setButtonImage', closeButtonImage);
1110		}
1111	}
1112	else {
1113		popupConfig.magicCall('setButtonImage', 'data:image/png;base64,'+popupData['sgpb-button-image-data']);
1114		if (popupData['sgpb-button-image-data'] == '' || popupData['sgpb-button-image-data'].indexOf('http') != -1) {
1115			popupConfig.magicCall('setButtonImage', popupData['sgpb-button-image']);
1116		}
1117	}
1118
1119};
1120
1121SGPBPopup.prototype.themeCustomizations = function()
1122{
1123	var popupId = this.getPopupId();
1124	var popupData = this.getPopupData();
1125	var popupConfig = this.getPopupConfig();
1126
1127	var contentOpacity = popupData['sgpb-content-opacity'];
1128	var contentBgColor = popupData['sgpb-background-color'];
1129	if (popupData['sgpb-background-image-data']) {
1130		var contentBgImage = 'data:image/png;base64,'+popupData['sgpb-background-image-data'];
1131	}
1132	else {
1133		var contentBgImage = popupData['sgpb-background-image'];
1134	}
1135	var showContentBackground = popupData['sgpb-show-background'];
1136	var contentBgImageMode = popupData['sgpb-background-image-mode'];
1137	var overlayColor = popupData['sgpb-overlay-color'];
1138	var popupTheme = popupData['sgpb-popup-themes'];
1139	var popupType = popupData['sgpb-type'];
1140	if (typeof popupData['sgpb-overlay-custom-class'] == 'undefined') {
1141		popupData['sgpb-overlay-custom-class'] = 'sgpb-popup-overlay';
1142	}
1143	if (typeof popupData['sgpb-popup-themes'] == 'undefined') {
1144		popupTheme = 'sgpb-theme-2';
1145	}
1146
1147	if (typeof showContentBackground == 'undefined') {
1148		contentBgColor = '';
1149		contentBgImage = '';
1150		contentBgImageMode = '';
1151	}
1152	if (typeof SgpbRecentSalesPopupType != 'undefined') {
1153		if (popupType == SgpbRecentSalesPopupType) {
1154			showContentBackground = 'on';
1155			contentBgColor = popupData['sgpb-background-color'];
1156			contentOpacity = popupData['sgpb-content-opacity'];
1157		}
1158	}
1159
1160	if (contentOpacity) {
1161		popupConfig.magicCall('setContentBackgroundOpacity', contentOpacity);
1162	}
1163	if (contentBgImageMode) {
1164		popupConfig.magicCall('setContentBackgroundMode', contentBgImageMode);
1165	}
1166	if (contentBgImage) {
1167		popupConfig.magicCall('setContentBackgroundImage', contentBgImage);
1168	}
1169	if (contentBgColor) {
1170		contentBgColor = SGPBPopup.hexToRgba(contentBgColor, contentOpacity);
1171		popupConfig.magicCall('setContentBackgroundColor', contentBgColor);
1172	}
1173	if (overlayColor) {
1174		popupConfig.magicCall('setOverlayColor', overlayColor);
1175	}
1176
1177	var overlayClasses = popupTheme+'-overlay sgpb-popup-overlay-'+popupId;
1178	if (SGPB_JS_PACKAGES.extensions['advanced-closing']) {
1179		if (typeof popupData['sgpb-enable-popup-overlay'] != 'undefined' && popupData['sgpb-enable-popup-overlay'] == 'on') {
1180			popupData['sgpb-enable-popup-overlay'] = true;
1181		}
1182		else if (typeof popupData['sgpb-enable-popup-overlay'] == 'undefined') {
1183			popupData['sgpb-enable-popup-overlay'] = false;
1184		}
1185	}
1186	else {
1187		popupData['sgpb-enable-popup-overlay'] = true;
1188	}
1189
1190	popupConfig.magicCall('setOverlayVisible', SGPBPopup.varToBool(popupData['sgpb-enable-popup-overlay']));
1191	if (typeof SgpbRecentSalesPopupType != 'undefined') {
1192		popupConfig.magicCall('setOverlayVisible', false);
1193	}
1194	if (SGPBPopup.varToBool(popupData['sgpb-enable-popup-overlay'])) {
1195		popupConfig.magicCall('setOverlayAddClass', overlayClasses + ' ' + popupData['sgpb-overlay-custom-class']);
1196		var overlayOpacity = popupData['sgpb-overlay-opacity'] || 0.8;
1197		popupConfig.magicCall('setOverlayOpacity', overlayOpacity * 100);
1198	}
1199};
1200
1201SGPBPopup.prototype.formSubmissionDetection = function(args)
1202{
1203	if (args.length) {
1204		return false;
1205	}
1206	var popupId = args.popupId;
1207	var options = SGPBPopup.getPopupOptionsById(popupId);
1208
1209	if (!options['sgpb-reopen-after-form-submission']) {
1210		return false;
1211	}
1212
1213	jQuery('.sgpb-popup-builder-content-' + popupId + ' form').submit(function() {
1214		SGPBPopup.setCookie('SGPBSubmissionReloadPopup', popupId);
1215	});
1216};
1217
1218SGPBPopup.prototype.htmlIframeFilterForOpen = function(popupId, popupEventName)
1219{
1220	var popupContent = jQuery('.sgpb-content-' + popupId);
1221
1222	if (!popupContent.length) {
1223		return false;
1224	}
1225
1226	popupContent.find('iframe').each(function() {
1227
1228		if (popupEventName != 'open') {
1229			/* for do not affect facebook type buttons iframe only */
1230			if (jQuery(this).closest('.fb_iframe_widget').length) {
1231				return true;
1232			}
1233
1234			/*close*/
1235			if (typeof jQuery(this).attr('data-attr-src') == 'undefined') {
1236				var src = jQuery(this).attr('src');
1237				if (src != '') {
1238					jQuery(this).attr('data-attr-src', src);
1239					jQuery(this).attr('src', '');
1240				}
1241				return true;
1242			}
1243			else {
1244				var src = jQuery(this).attr('src');
1245				if (src != '') {
1246					jQuery(this).attr('data-attr-src', src);
1247					jQuery(this).attr('src', '');
1248				}
1249				return true;
1250			}
1251		}
1252		else {
1253			/*open*/
1254			if (typeof jQuery(this).attr('data-attr-src') == 'undefined') {
1255				var src = jQuery(this).attr('src');
1256				if (src != '') {
1257					jQuery(this).attr('data-attr-src', src);
1258				}
1259
1260				return true;
1261			}
1262			else {
1263				var src = jQuery(this).attr('data-attr-src');
1264				if (src != '') {
1265					jQuery(this).attr('src', src);
1266					jQuery(this).attr('data-attr-src', src);
1267				}
1268				return true;
1269			}
1270		}
1271	});
1272};
1273
1274SGPBPopup.prototype.iframeSizesInHtml = function(args)
1275{
1276	var popupId = args['popupId'];
1277	var popupOptions = args.popupData;
1278	var popupContent = jQuery('.sgpb-content-' + popupId);
1279
1280	if (!popupContent.length) {
1281		return false;
1282	}
1283	popupContent.find('iframe').each(function() {
1284		if (typeof jQuery(this) == 'undefined') {
1285			return false;
1286		}
1287		if (popupOptions['sgpb-popup-dimension-mode'] == 'customMode') {
1288			if (typeof jQuery(this).attr('width') == 'undefined' && typeof popupContent.attr('height') == 'undefined') {
1289				jQuery(this).css({'width': popupOptions['sgpb-width'], 'height': popupOptions['sgpb-height']});
1290			}
1291		}
1292	});
1293};
1294
1295SGPBPopup.prototype.getSearchDataFromContent = function(content)
1296{
1297	var pattern = /\[(\[?)(pbvariable)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]\*+(?:\[(?!\/\2\])[^\[]\*+)\*+)\[\/\2\])?)(\]?)/gi;
1298	var match;
1299	var collectedData = [];
1300
1301	while (match = pattern.exec(content)) {
1302		var currentSearchData = [];
1303		var attributes;
1304		var attributesKeyValue = [];
1305		var parseAttributes = /\s(\w+?)="(.+?)"/g;
1306		currentSearchData['replaceString'] = this.htmlDecode(match[0]);
1307
1308		while (attributes = parseAttributes.exec(match[3])) {
1309			attributesKeyValue[attributes[1]] = this.htmlDecode(attributes[2]);
1310		}
1311
1312		currentSearchData['searchData'] = attributesKeyValue;
1313		collectedData.push(currentSearchData);
1314	}
1315
1316	return collectedData;
1317};
1318
1319SGPBPopup.prototype.replaceWithCustomShortcode = function(popupId)
1320{
1321	var currentHtmlContent = jQuery('.sgpb-content-'+popupId).html();
1322	var searchData = this.getSearchDataFromContent(currentHtmlContent);
1323	var that = this;
1324
1325	if (!searchData.length) {
1326		return false;
1327	}
1328
1329	for (var index in searchData) {
1330		var currentSearchData = searchData[index];
1331		var searchAttributes = currentSearchData['searchData'];
1332
1333		if (typeof searchAttributes['selector'] == 'undefined' || typeof searchAttributes['attribute'] == 'undefined') {
1334			that.replaceShortCode(currentSearchData['replaceString'], '', popupId);
1335			continue;
1336		}
1337
1338		try {
1339			if (!jQuery(searchAttributes['selector']).length) {
1340				that.replaceShortCode(currentSearchData['replaceString'], '', popupId);
1341				continue;
1342			}
1343		}
1344		catch (e) {
1345			that.replaceShortCode(currentSearchData['replaceString'], '', popupId);
1346			continue;
1347		}
1348
1349		if (searchAttributes['attribute'] == 'text') {
1350			var replaceName = jQuery(searchAttributes['selector']).text();
1351		}
1352		else {
1353			var replaceName = jQuery(searchAttributes['selector']).attr(searchAttributes['attribute']);
1354		}
1355
1356		if (typeof replaceName == 'undefined') {
1357			that.replaceShortCode(currentSearchData['replaceString'], '', popupId);
1358			continue;
1359		}
1360
1361		that.replaceShortCode(currentSearchData['replaceString'], replaceName, popupId);
1362	}
1363};
1364
1365SGPBPopup.prototype.replaceShortCode = function(shortCode, replaceText, popupId)
1366{
1367	var popupId = parseInt(popupId);
1368
1369	if (!popupId) {
1370		return false;
1371	}
1372
1373	var popupContentWrapper = jQuery('.sgpb-content-' + popupId);
1374
1375	if (!popupContentWrapper.length) {
1376		return false;
1377	}
1378
1379	popupContentWrapper.find('div').each(function() {
1380		var currentHtmlContent = jQuery(this).contents();
1381
1382		if (!currentHtmlContent.length) {
1383			return false;
1384		}
1385
1386		currentHtmlContent.html(function(i, v) {
1387			if (typeof v != 'undefined') {
1388				return v.replace(shortCode, replaceText);
1389			}
1390		});
1391	});
1392
1393	return true;
1394};
1395
1396SGPBPopup.prototype.popupTriggeringListeners = function()
1397{
1398	var that = this;
1399	var popupData = this.getPopupData();
1400	var popupConfig = this.getPopupConfig();
1401
1402	sgAddEvent(window, 'sgpbDidOpen', function(e) {
1403		var args = e.detail;
1404		that.iframeSizesInHtml(args);
1405		that.formSubmissionDetection(args);
1406		var popupOptions = args.popupData;
1407
1408		var closeButtonDelay = parseInt(popupOptions['sgpb-close-button-delay']);
1409		if (closeButtonDelay) {
1410			that.closeButtonDisplay(popupOptions['sgpb-post-id'], 'show', closeButtonDelay);
1411		}
1412		var disablePageScrolling = popupOptions['sgpb-disable-page-scrolling'];
1413		if (popupOptions['sgpb-overlay-color']) {
1414			jQuery('.sgpb-theme-1-overlay').css({'background-image': 'none'});
1415		}
1416		if (SGPBPopup.varToBool(disablePageScrolling)) {
1417			jQuery('html').addClass('sgpb-overflow-hidden');
1418			jQuery('body').addClass('sgpb-overflow-hidden-body');
1419		}
1420	});
1421
1422	sgAddEvent(window, 'sgpbWillOpen', function(e) {
1423		var args = e.detail;
1424		var popupId = parseInt(args['popupId']);
1425		that.htmlIframeFilterForOpen(args.popupId, 'open');
1426		that.replaceWithCustomShortcode(popupId);
1427		that.sgpbDontShowPopup(popupId);
1428
1429		var closeButtonDelay = parseInt(popupData['sgpb-close-button-delay']);
1430		if (closeButtonDelay) {
1431			that.closeButtonDisplay(popupData['sgpb-post-id'], 'hide');
1432		}
1433		/* extra checker for analytics */
1434		var settings = {
1435			popupId: popupData['sgpb-post-id'],
1436			disabledAnalytics: popupData['sgpb-popup-counting-disabled'],
1437			disabledInGeneral: SGPB_POPUP_PARAMS.disableAnalyticsGeneral
1438		};
1439		jQuery(window).trigger('sgpbDisableAnalytics', settings);
1440	});
1441
1442	sgAddEvent(window, 'sgpbShouldClose', function(e) {
1443
1444	});
1445
1446	sgAddEvent(window, 'sgpbWillClose', function(e) {
1447		var args = e.detail;
1448		SGPBPopup.offPopup(e.detail.currentObj);
1449	});
1450};
1451
1452SGPBPopup.prototype.sgpbDontShowPopup = function(popupId)
1453{
1454	var dontShowPopup = jQuery('.sgpb-content-' + popupId).parent().find('[class*="sg-popup-dont-show"]');
1455	if (!dontShowPopup.length) {
1456		return false;
1457	}
1458
1459	dontShowPopup.each(function() {
1460		jQuery(this).bind('click', function(e) {
1461			e.preventDefault();
1462			var expireTime = SGPB_POPUP_PARAMS.dontShowPopupExpireTime;
1463			var cookieName = 'sgDontShowPopup' + popupId;
1464			var classNameSearch = jQuery(this).attr('class').match(/sg-popup-dont-show/);
1465			var className = classNameSearch['input'];
1466			var customExpireTime = className.match(/sg-popup-dont-show-(\d+$)/);
1467
1468			if (customExpireTime) {
1469				expireTime = parseInt(customExpireTime[1]);
1470			}
1471
1472			SGPBPopup.setCookie(cookieName, expireTime, expireTime);
1473			SGPBPopup.closePopupById(popupId);
1474		});
1475	});
1476};
1477
1478SGPBPopup.prototype.addToCounter = function(popupOptions)
1479{
1480	if (SGPB_POPUP_PARAMS.isPreview || (typeof popupOptions['sgpb-popup-counting-disabled'] != 'undefined')) {
1481		return false;
1482	}
1483	var that = this;
1484	var openedPopups = window.sgpbOpenedPopup || {};
1485
1486
1487	var popupId = parseInt(popupOptions['sgpb-post-id']);
1488
1489	if (typeof openedPopups[popupId] == 'undefined') {
1490		openedPopups[popupId] = 1;
1491	}
1492	else {
1493		openedPopups[popupId] += 1;
1494	}
1495	window.sgpbOpenedPopup = openedPopups;
1496};
1497
1498/*
1499 * closeButtonDisplay()
1500 * close or hide close button
1501 * @param popupId
1502 * @param display
1503 * @param delay
1504 */
1505
1506SGPBPopup.prototype.closeButtonDisplay = function(popupId, display, delay)
1507{
1508	if (display == 'show') {
1509		setTimeout(function() {
1510				jQuery('.sgpb-content-' + popupId).prev().show();
1511			},
1512			delay * 1000 /* received values covert to milliseconds */
1513		);
1514	}
1515	else if (display == 'hide') {
1516		jQuery('.sgpb-content-' + popupId).prev().hide();
1517	}
1518};
1519
1520SGPBPopup.prototype.open = function(args)
1521{
1522	var customEvent = this.customEvent;
1523	var config = this.getPopupConfig();
1524	var popupId = this.getPopupId();
1525	var eventName = this.eventName;
1526
1527	if (typeof window.sgPopupBuilder == 'undefined') {
1528		window.sgPopupBuilder = [];
1529	}
1530	var popupData = SGPBPopup.getPopupWindowDataById(popupId);
1531
1532	if (!popupData) {
1533		window.SGPB_ORDER += 1;
1534		var currentObj = {
1535			'eventName': eventName,
1536			'popupId': popupId,
1537			'order': window.SGPB_ORDER,
1538			'isOpen': true,
1539			'sgpbPopupObj': this
1540		};
1541		config.currentObj = currentObj;
1542		var popupConfig = config.combineConfigObj();
1543		var popup = new SGPopup(popupConfig);
1544		currentObj.popup = popup;
1545		window.sgPopupBuilder.push(currentObj);
1546	}
1547	else {
1548		popup = popupData['popup'];
1549		popupData['isOpen'] = true;
1550	}
1551
1552	if (typeof args != 'undefined' && !args['countPopupOpen']) {
1553		/* don't allow to count popup opening */
1554		this.setCountPopupOpen(false);
1555	}
1556	popup.customEvent = customEvent;
1557	popup.open();
1558	this.setPopupObj(popup);
1559
1560	/* contact form 7 form submission
1561	 * TODO: this must be moved to a better place in the future
1562	 * I'm leaving it here for now, since sgpbDidOpen() gets called way too much!
1563	 */
1564	var options = SGPBPopup.getPopupOptionsById(popupId);
1565	SgpbEventListener.CF7EventListener(popupId, options);
1566	if (typeof options['sgpb-behavior-after-special-events'] != 'undefined') {
1567		if (options['sgpb-behavior-after-special-events'].length) {
1568			options = options['sgpb-behavior-after-special-events'][0][0];
1569			if (options['param'] == 'contact-form-7') {
1570				SgpbEventListener.processCF7MailSent(popupId, options);
1571			}
1572		}
1573	}
1574};
1575
1576SGPBPopup.varToBool = function(optionName)
1577{
1578	var returnValue = optionName ? true : false;
1579
1580	return returnValue;
1581};
1582
1583SGPBPopup.hexToRgba = function(hex, opacity)
1584{
1585	var c;
1586	if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
1587		c = hex.substring(1).split('');
1588
1589		if (c.length == 3){
1590			c= [c[0], c[0], c[1], c[1], c[2], c[2]];
1591		}
1592		c = '0x'+c.join('');
1593		return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+','+opacity+')';
1594	}
1595	throw new Error('Bad Hex');
1596};
1597
1598SGPBPopup.prototype.contentCopyToClick = function()
1599{
1600	var popupData = this.getPopupData();
1601	var popupId = this.getPopupId();
1602
1603	var tempInputId = 'content-copy-to-click-'+popupId;
1604	var value = this.htmlDecode(popupData['sgpb-copy-to-clipboard-text']);
1605	var tempInput = document.createElement("input");
1606	tempInput.id = tempInputId;
1607	tempInput.value = value;
1608	tempInput.style = 'position: absolute; right: -10000px';
1609	if (!document.getElementById(tempInputId)) {
1610		document.body.appendChild(tempInput);
1611	}
1612	tempInput.select();
1613	document.execCommand("copy");
1614	document.body.removeChild(tempInput);
1615};
1616
1617SGPBPopup.prototype.htmlDecode = function(value)
1618{
1619	return jQuery('<textarea/>').html(value).text();
1620};
1621
1622SGPBPopup.prototype.findTargetInsideExceptionsList = function(targetName, exceptionList)
1623{
1624	var status = false;
1625	var popupContentMainDiv = document.getElementById('sgpb-popup-dialog-main-div');
1626
1627	while (targetName.parentNode) {
1628		targetName = targetName.parentNode;
1629		if (typeof targetName.tagName == 'undefined') {
1630			continue;
1631		}
1632		var tagName = targetName.tagName.toLowerCase();
1633		if (targetName === popupContentMainDiv) {
1634			break;
1635		}
1636		if (exceptionList.indexOf(tagName) != -1) {
1637			status =  true;
1638			break;
1639		}
1640	}
1641
1642	return status;
1643};
1644
1645SGPBPopup.prototype.contentCloseBehavior = function()
1646{
1647	var that = this;
1648	var popupData = this.getPopupData();
1649	var popupId = this.getPopupId();
1650	var redirectUrl = popupData['sgpb-click-redirect-to-url'];
1651	var contentClickBehavior = popupData['sgpb-content-click-behavior'];
1652	var redirectToNewTab = SGPBPopup.varToBool(popupData['sgpb-redirect-to-new-tab']);
1653	var closePopupAfterCopy = SGPBPopup.varToBool(popupData['sgpb-copy-to-cl
1653ipboard-close-popup']);
1654	var clipboardAlert = SGPBPopup.varToBool(popupData['sgpb-copy-to-clipboard-alert']);
1655
1656	var separators = ['&amp;', '/&/g'];
1657	for (var i in separators) {
1658		redirectUrl = redirectUrl.split(separators[i]).join('&');
1659	}
1660
1661	sgAddEvent(window, 'sgpbDidOpen', function(e) {
1662
1663	});
1664	sgAddEvent(window, 'sgpbWillOpen', function(e) {
1665		if (popupId != e.detail.popupId || e.detail.popupData['sgpb-content-click'] == 'undefined') {
1666			return false;
1667		}
1668		if (contentClickBehavior == 'redirect') {
1669			jQuery('.sgpb-content-'+popupId).addClass('sgpb-cursor-pointer');
1670		}
1671		jQuery('.sgpb-content-'+e.detail.popupId).on('click', function(event) {
1672			/* we need this settings in analytics */
1673			var settings = {
1674				popupId: popupId,
1675				eventName: 'sgpbPopupContentClick'
1676			};
1677			jQuery(window).trigger('sgpbPopupContentClick', settings);
1678
1679			if (contentClickBehavior == 'redirect') {
1680				if (redirectToNewTab) {
1681					window.open(redirectUrl);
1682					SGPBPopup.closePopupById(that.getPopupId());
1683					return;
1684				}
1685				window.location = redirectUrl;
1686				SGPBPopup.closePopupById(that.getPopupId());
1687			}
1688			else if (contentClickBehavior == 'copy') {
1689				var exceptionList = ['input', 'textarea', 'select', 'button', 'a'];
1690				var targetName = event.target.tagName.toLowerCase();
1691				var parentTagName = event.target.parentNode.tagName.toLowerCase();
1692				var parentsIsInExceptionsList = that.findTargetInsideExceptionsList(event.target, exceptionList);
1693
1694				/*for do not copy when user click to any input element*/
1695				if (exceptionList.indexOf(targetName) == -1 && !parentsIsInExceptionsList) {
1696					that.contentCopyToClick();
1697
1698					if (closePopupAfterCopy) {
1699						SGPBPopup.closePopupById(that.getPopupId());
1700					}
1701					if (clipboardAlert) {
1702						alert(popupData['sgpb-copy-to-clipboard-message'])
1703					}
1704				}
1705			}
1706			else if (popupData['sgpb-disable-popup-closing'] != 'on') {
1707				SGPBPopup.closePopupById(that.getPopupId());
1708			}
1709		});
1710	});
1711
1712	sgAddEvent(window, 'sgpbDidClose', function(e) {
1713
1714	});
1715};
1716
1717SGPBPopup.prototype.addFixedPosition = function()
1718{
1719	var popupData = this.getPopupData();
1720	var popupId = this.getPopupId();
1721	var popupConfig = this.getPopupConfig();
1722
1723	var fixedPosition = popupData['sgpb-popup-fixed-position'];
1724	var positionRight = '';
1725	var positionTop = '';
1726	var positionBottom = '';
1727	var positionLeft = '';
1728
1729	if (fixedPosition == 1) {
1730		positionTop = 40;
1731		positionLeft = 20;
1732	}
1733	else if (fixedPosition == 2) {
1734		positionLeft = 'center';
1735		positionTop = 40;
1736	}
1737	else if (fixedPosition == 3) {
1738		positionTop = 40;
1739		positionRight = 20;
1740	}
1741	else if (fixedPosition == 4) {
1742		positionTop = 'center';
1743		positionLeft = 20;
1744	}
1745	else if (fixedPosition == 6) {
1746		positionTop = 'center';
1747		positionRight = 20;
1748	}
1749	else if (fixedPosition == 7) {
1750		positionLeft = 20;
1751		positionBottom = 2;
1752	}
1753	else if (fixedPosition == 8) {
1754		positionLeft = 'center';
1755		positionBottom = 2;
1756	}
1757	else if (fixedPosition == 9) {
1758		positionRight = 20;
1759		positionBottom = 2;
1760	}
1761
1762	if (typeof SgpbRecentSalesPopupType != 'undefined') {
1763		if (popupData['sgpb-type'] == SgpbRecentSalesPopupType) {
1764			if (positionTop != '') {
1765				positionTop = parseInt(positionTop+10);
1766			}
1767			else if (positionBottom != '') {
1768				positionBottom = parseInt(positionBottom+10);
1769			}
1770		}
1771	}
1772	popupConfig.magicCall('setPositionTop', positionTop);
1773	popupConfig.magicCall('setPositionRight', positionRight);
1774	popupConfig.magicCall('setPositionBottom', positionBottom);
1775	popupConfig.magicCall('setPositionLeft', positionLeft);
1776};
1777
1778SGPBPopup.prototype.setPopupDimensions = function()
1779{
1780	var popupData = this.getPopupData();
1781	var popupConfig = this.getPopupConfig();
1782	var popupId = this.getPopupId();
1783	var dimensionData = popupData['sgpb-popup-dimension-mode'];
1784	var maxWidth = popupData['sgpb-max-width'];
1785	var maxHeight = popupData['sgpb-max-height'];
1786	var minWidth = popupData['sgpb-min-width'];
1787	var minHeight = popupData['sgpb-min-height'];
1788	var contentPadding = popupData['sgpb-content-padding'];
1789	var popupType = popupData['sgpb-type'];
1790
1791	popupConfig.magicCall('setMaxWidth', maxWidth);
1792	popupConfig.magicCall('setMaxHeight', maxHeight);
1793	popupConfig.magicCall('setMinWidth', minWidth);
1794	popupConfig.magicCall('setMinHeight', minHeight);
1795
1796	if (popupType == 'image') {
1797		popupConfig.magicCall('setContentBackgroundImage', popupData['sgpb-image-url']);
1798		popupConfig.magicCall('setContentBackgroundMode', 'contain');
1799		if (dimensionData == 'customMode') {
1800			popupConfig.magicCall('setContentBackgroundPosition', 'center center');
1801		}
1802	}
1803	if (dimensionData == 'responsiveMode') {
1804		var dimensionMeasure = popupData['sgpb-responsive-dimension-measure'];
1805		/* for image popup type and responsive mode, set background image to fit */
1806		if (popupType == 'image' && dimensionMeasure != 'fullScreen') {
1807			popupConfig.magicCall('setContentBackgroundMode', 'fit');
1808			this.setMaxWidthForResponsiveImage();
1809		}
1810
1811		var popupConfig = this.getPopupConfig();
1812		if (dimensionMeasure != 'auto') {
1813			popupConfig.magicCall('setWidth', dimensionMeasure+'%');
1814
1815			popupConfig.magicCall('setContentBackgroundPosition', 'center');
1816		}
1817		else {
1818			var widthToSet = jQuery('.sgpb-popup-builder-content-'+popupId).width() + (contentPadding*2);
1819
1820			if (isNaN(widthToSet)) {
1821				widthToSet = 'auto';
1822			}
1823			else {
1824				popupConfig.magicCall('setContentBackgroundPosition', 'center center');
1825				widthToSet += 'px';
1826			}
1827
1828			popupConfig.magicCall('setWidth', widthToSet);
1829			if (dimensionMeasure == 'fullScreen') {
1830				popupConfig.magicCall('setHeight', widthToSet);
1831			}
1832		}
1833
1834		return popupConfig;
1835	}
1836
1837	var popupWidth = popupData['sgpb-width'];
1838	var popupHeight = popupData['sgpb-height'];
1839
1840	popupConfig.magicCall('setWidth', popupWidth);
1841	popupConfig.magicCall('setHeight', popupHeight);
1842
1843	return popupConfig;
1844};
1845
1846SGPBPopup.prototype.setMaxWidthForResponsiveImage = function()
1847{
1848	var popupData = this.getPopupData();
1849	var popupConfig = this.getPopupConfig();
1850	var dimensionMeasure = popupData['sgpb-responsive-dimension-measure'];
1851
1852	if (dimensionMeasure != 'auto') {
1853		var maxWidth = popupData['sgpb-max-width'];
1854		if (maxWidth == '') {
1855			popupConfig.magicCall('setMaxWidth', dimensionMeasure+'%');
1856			return true;
1857		}
1858		popupConfig.magicCall('setMaxWidth', dimensionMeasure+'%');
1859		if (maxWidth.indexOf('%') != '-1') {
1860			if (parseInt(maxWidth) < dimensionMeasure) {
1861				popupConfig.magicCall('setMaxWidth', maxWidth);
1862			}
1863		}
1864		else {
1865			var responsiveMeasureInPx = (dimensionMeasure*window.innerWidth)/100;
1866			if (maxWidth < responsiveMeasureInPx) {
1867				popupConfig.magicCall('setMaxWidth', maxWidth);
1868			}
1869		}
1870	}
1871};
1872SGPBPopup.JSONParse = function(data){
1873	return JSON.parse(atob(data, true));
1874};
1875
1876// unused function!
1877SGPBPopup.b64DecodeUnicode = function(str)
1878{
1879	var Base64 = {
1880
1881		/* private property */
1882		_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
1883
1884		/* public method for decoding */
1885		decode : function (input) {
1886			var output = "";
1887			var chr1, chr2, chr3;
1888			var enc1, enc2, enc3, enc4;
1889			var i = 0;
1890
1891			input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
1892
1893			while (i < input.length) {
1894				enc1 = this._keyStr.indexOf(input.charAt(i++));
1895				enc2 = this._keyStr.indexOf(input.charAt(i++));
1896				enc3 = this._keyStr.indexOf(input.charAt(i++));
1897				enc4 = this._keyStr.indexOf(input.charAt(i++));
1898
1899				chr1 = (enc1 << 2) | (enc2 >> 4);
1900				chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
1901				chr3 = ((enc3 & 3) << 6) | enc4;
1902
1903				output += String.fromCharCode(chr1);
1904
1905				if (enc3 != 64) {
1906					output += String.fromCharCode(chr2);
1907				}
1908				if (enc4 != 64) {
1909					output += String.fromCharCode(chr3);
1910				}
1911
1912			}
1913
1914			output = Base64._utf8_decode(output);
1915
1916			return output;
1917
1918		},
1919
1920		/* private method for UTF-8 decoding */
1921		_utf8_decode : function (utftext) {
1922			var string = "";
1923			var i = 0;
1924			var c = c1 = c2 = 0;
1925
1926			while (i < utftext.length) {
1927
1928				c = utftext.charCodeAt(i);
1929
1930				if (c < 128) {
1931					string += String.fromCharCode(c);
1932					i++;
1933				}
1934				else if ((c > 191) && (c < 224)) {
1935					c2 = utftext.charCodeAt(i+1);
1936					string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
1937					i += 2;
1938				}
1939				else {
1940					c2 = utftext.charCodeAt(i+1);
1941					c3 = utftext.charCodeAt(i+2);
1942					string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
1943					i += 3;
1944				}
1945			}
1946
1947			return string;
1948		}
1949	};
1950
1951	return Base64.decode(str);
1952};
1953
1954// unused function!
1955SGPBPopup.unserialize_old = function(data)
1956{
1957	data = SGPBPopup.b64DecodeUnicode(data);
1958
1959	var $global = (typeof window !== 'undefined' ? window : global);
1960
1961	var utf8Overhead = function(str) {
1962		var s = str.length;
1963		for (var i = str.length - 1; i >= 0; i--) {
1964			var code = str.charCodeAt(i);
1965			if (code > 0x7f && code <= 0x7ff) {
1966				s++;
1967			}
1968			else if (code > 0x7ff && code <= 0xffff) {
1969				s += 2;
1970			}
1971			/* trail surrogate */
1972			if (code >= 0xDC00 && code <= 0xDFFF) {
1973				i--;
1974			}
1975		}
1976		return s - 1;
1977	};
1978
1979	var error = function(type, msg, filename, line) {
1980		throw new $global[type](msg, filename, line);
1981	};
1982	var readUntil = function(data, offset, stopchr) {
1983		var i = 2;
1984		var buf = [];
1985		var chr = data.slice(offset, offset + 1);
1986
1987		while (chr !== stopchr) {
1988			if ((i + offset) > data.length) {
1989				error('Error', 'Invalid');
1990			}
1991			buf.push(chr);
1992			chr = data.slice(offset + (i - 1), offset + i);
1993			i += 1;
1994		}
1995		return [buf.length, buf.join('')];
1996	};
1997	var readChrs = function(data, offset, length) {
1998		var i, chr, buf;
1999
2000		buf = [];
2001		for (i = 0; i < length; i++) {
2002			chr = data.slice(offset + (i - 1), offset + i);
2003			buf.push(chr);
2004			length -= utf8Overhead(chr);
2005		}
2006		return [buf.length, buf.join('')];
2007	};
2008	function _unserialize(data, offset) {
2009		var dtype;
2010		var dataoffset;
2011		var keyandchrs;
2012		var keys;
2013		var contig;
2014		var length;
2015		var array;
2016		var readdata;
2017		var readData;
2018		var ccount;
2019		var stringlength;
2020		var i;
2021		var key;
2022		var kprops;
2023		var kchrs;
2024		var vprops;
2025		var vchrs;
2026		var value;
2027		var chrs = 0;
2028		var typeconvert = function(x) {
2029			return x
2030		};
2031
2032		if (!offset) {
2033			offset = 0
2034		}
2035		dtype = (data.slice(offset, offset + 1)).toLowerCase();
2036
2037		dataoffset = offset + 2;
2038
2039		switch (dtype) {
2040			case 'i':
2041				typeconvert = function(x) {
2042					return parseInt(x, 10);
2043				};
2044				readData = readUntil(data, dataoffset, ';');
2045				chrs = readData[0];
2046				readdata = readData[1];
2047				dataoffset += chrs + 1;
2048				break;
2049			case 'b':
2050				typeconvert = function(x) {
2051					return parseInt(x, 10) !== 0;
2052				};
2053				readData = readUntil(data, dataoffset, ';');
2054				chrs = readData[0];
2055				readdata = readData[1];
2056				dataoffset += chrs + 1;
2057				break;
2058			case 'd':
2059				typeconvert = function(x) {
2060					return parseFloat(x);
2061				};
2062				readData = readUntil(data, dataoffset, ';');
2063				chrs = readData[0];
2064				readdata = readData[1];
2065				dataoffset += chrs + 1;
2066				break;
2067			case 'n':
2068				readdata = null;
2069				break;
2070			case 's':
2071				ccount = readUntil(data, dataoffset, ':');
2072				chrs = ccount[0];
2073				stringlength = ccount[1];
2074				dataoffset += chrs + 2;
2075
2076				readData = readChrs(data, dataoffset + 1, parseInt(stringlength, 10));
2077				chrs = readData[0];
2078				readdata = readData[1];
2079				dataoffset += chrs + 2;
2080				if (chrs !== parseInt(stringlength, 10) && chrs !== readdata.length) {
2081					error('SyntaxError', 'String length mismatch')
2082				}
2083				break;
2084			case 'a':
2085				readdata = {};
2086
2087				keyandchrs = readUntil(data, dataoffset, ':');
2088				chrs = keyandchrs[0];
2089				keys = keyandchrs[1];
2090				dataoffset += chrs + 2;
2091
2092				length = parseInt(keys, 10);
2093				contig = true;
2094
2095				for (i = 0; i < length; i++) {
2096					kprops = _unserialize(data, dataoffset);
2097					kchrs = kprops[1];
2098					key = kprops[2];
2099					dataoffset += kchrs;
2100
2101					vprops = _unserialize(data, dataoffset);
2102					vchrs = vprops[1];
2103					value = vprops[2];
2104					dataoffset += vchrs;
2105
2106					if (key !== i) {
2107						contig = false;
2108					}
2109
2110					readdata[key] = value;
2111				}
2112
2113				if (contig) {
2114					array = new Array(length);
2115					for (i = 0; i < length; i++) {
2116						array[i] = readdata[i];
2117					}
2118					readdata = array;
2119				}
2120
2121				dataoffset += 1;
2122				break;
2123			default:
2124				error('SyntaxError', 'Unknown / Unhandled data type(s): ' + dtype);
2125				break;
2126		}
2127
2128		return [dtype, dataoffset - offset, typeconvert(readdata)]
2129	}
2130
2131	return _unserialize((data + ''), 0)[2];
2132};
2133
2134SGPBPopup.closePopup = function()
2135{
2136	var popupObjs = window.sgPopupBuilder;
2137	var lastPopupObj = this.getLastPopup();
2138
2139	if (typeof lastPopupObj == 'undefined') {
2140		return false;
2141	}
2142
2143	var popupId = lastPopupObj.popupId;
2144
2145	SGPBPopup.closePopupById(popupId);
2146};
2147
2148SGPBPopup.closePopupById = function(popupId)
2149{
2150	var popupObjs = window.sgPopupBuilder;
2151	if (!popupObjs.length) {
2152		return;
2153	}
2154
2155	for (var i in popupObjs) {
2156
2157		var currentObj = popupObjs[i];
2158
2159		if (currentObj.popupId == popupId) {
2160			var popupObj = popupObjs[i]['popup'];
2161			if (popupObj) {
2162				/*Send true argument to don’t count disable popup option*/
2163				popupObj.close(true);
2164			}
2165		}
2166	}
2167};
2168
2169SGPBPopup.getPopupWindowDataById = function(popupId)
2170{
2171	var popups = window.sgPopupBuilder;
2172	var popup = false;
2173
2174	if (typeof popups == 'undefined' || !popups.length) {
2175		return popup;
2176	}
2177
2178	for (var i in popups) {
2179		var popupData = popups[i];
2180
2181		if (popupData.popupId == popupId) {
2182			popup = popupData;
2183			break;
2184		}
2185	}
2186
2187	return popup;
2188};
2189
2190SGPBPopup.findPopupObjById = function(popupId)
2191{
2192	var popup = false;
2193	var popupData = SGPBPopup.getPopupWindowDataById(popupId);
2194
2195	if (popupData) {
2196		popup = popupData['popup'];
2197	}
2198
2199	return popup;
2200};
2201
2202SGPBPopup.getLastPopup = function()
2203{
2204	var popups = window.sgPopupBuilder;
2205	var popup = false;
2206
2207	if (!popups.length) {
2208		return popup;
2209	}
2210
2211	var searchPopups = [].concat(popups);
2212
2213	for (var i in searchPopups) {
2214		var popupData = searchPopups[i];
2215
2216		if (popupData.isOpen) {
2217			popup = popupData;
2218			break;
2219		}
2220	}
2221
2222	return popup;
2223};
2224
2225SGPBPopup.offPopup = function(currentPopup)
2226{
2227	var popups = window.sgPopupBuilder;
2228
2229	if (!popups.length) {
2230		return false;
2231	}
2232
2233	for (var i in popups) {
2234		var popupData = popups[i];
2235
2236		if (popupData.order == currentPopup.order && popupData.eventName == currentPopup.eventName) {
2237			popups[i]['isOpen'] = false;
2238			break;
2239		}
2240	}
2241
2242	return true;
2243};
2244
2245SGPBPopup.capitalizeFirstLetter = function(string)
2246{
2247	return string.charAt(0).toUpperCase() + string.slice(1);
2248};
2249
2250SGPBPopup.getParamFromUrl = function(param)
2251{
2252	var url = window.location.href;
2253	param = param.replace(/[\[\]]/g, "\\$&");
2254	var regex = new RegExp("[?&]" + param + "(=([^&#]*)|&|#|$)"),
2255		results = regex.exec(url);
2256	if (!results) {
2257		return null;
2258	}
2259	if (!results[2]) {
2260		return '';
2261	}
2262	return decodeURIComponent(results[2].replace(/\+/g, " "));
2263};
2264
2265/*
2266 *
2267 * SGPBPopup Cookies' settings
2268 *
2269 */
2270SGPBPopup.setCookie = function(cName, cValue, exDays, cPageLevel)
2271{
2272	var sameSite = 'Lax';
2273	var isPreview = SGPBPopup.getParamFromUrl('preview');
2274	if (isPreview) {
2275		return false;
2276	}
2277	var expirationDate = new Date();
2278	var cookiePageLevel = '';
2279	var cookieExpirationData = 1;
2280	if (!exDays || isNaN(exDays)) {
2281		if (!exDays && exDays === 0) {
2282			exDays = 'session';
2283		}
2284		else {
2285			exDays = 365*50;
2286		}
2287	}
2288
2289	if (!Boolean(cPageLevel)) {
2290		cookiePageLevel = 'path=/;';
2291	}
2292
2293	if (exDays == 'session') {
2294		cookieExpirationData = 0;
2295	}
2296	else {
2297		expirationDate.setDate(parseInt(expirationDate.getDate() + parseInt(exDays)));
2298		cookieExpirationData = expirationDate.toUTCString();
2299	}
2300	var expires = 'expires='+cookieExpirationData;
2301	if (exDays == -1) {
2302		expires = '';
2303	}
2304
2305	if (!cookieExpirationData) {
2306		expires = '';
2307	}
2308
2309	/* in IE there is no need to specify the path */
2310	if (SGPBPopup.isIE()) {
2311		cookiePageLevel = '';
2312	}
2313
2314	var value = cValue+((exDays == null) ? ';' : '; '+expires+';'+cookiePageLevel+'; SameSite=' + sameSite);
2315	document.cookie = cName + '=' + value;
2316};
2317
2318SGPBPopup.isIE = function()
2319{
2320	ua = navigator.userAgent;
2321	/* MSIE used to detect old browsers and Trident used to newer ones*/
2322	var isIe = ua.indexOf('MSIE ') > -1 || ua.indexOf('Trident/') > -1;
2323
2324	return isIe;
2325};
2326
2327SGPBPopup.getCookie = function(cName)
2328{
2329	var name = cName + '=';
2330	var ca = document.cookie.split(';');
2331	for (var i = 0; i < ca.length; i++) {
2332		var c = ca[i];
2333		while (c.charAt(0) == ' ') {
2334			c = c.substring(1);
2335		}
2336		if (c.indexOf(name) == 0) {
2337			return c.substring(name.length, c.length);
2338		}
2339	}
2340
2341	return '';
2342};
2343
2344/*
2345 *
2346 * Delete the cookie by expiring it
2347 *
2348 */
2349
2350SGPBPopup.deleteCookie = function(cName, cPath)
2351{
2352	if (!cPath) {
2353		cPath = 'path=/;';
2354	}
2355
2356	document.cookie = cName + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;' + cPath;
2357};
2358
2359/**
2360 *
2361 * @SgpbEventListener listen Events and call corresponding events
2362 *
2363 */
2364
2365function SgpbEventListener()
2366{
2367	this.evenets = null;
2368	this.popupObj = {};
2369}
2370
2371SgpbEventListener.inactivityIdicator = 0;
2372
2373SgpbEventListener.prototype.setEvents = function(events)
2374{
2375	this.evenets = events;
2376};
2377
2378SgpbEventListener.prototype.getEvents = function()
2379{
2380	return this.evenets;
2381};
2382
2383SgpbEventListener.prototype.setPopupObj = function(popupObj)
2384{
2385	this.popupObj = popupObj;
2386};
2387
2388SgpbEventListener.prototype.getPopupObj = function()
2389{
2390	return this.popupObj;
2391};
2392
2393SgpbEventListener.eventsListenerAfterDocumentReady = function()
2394{
2395	window.SGPB_SOUND = [];
2396
2397	sgAddEvent(window, 'sgpbDidOpen', function(e) {
2398
2399		//Modern browsers block autoplay with sound unless the user has interacted with the page
2400		//SGPBPopup.playMusic(e);
2401
2402		const pbsgsoundnotification = document.querySelector("#pbsgsoundnotification");
2403		if (pbsgsoundnotification) {
2404	       pbsgsoundnotification.addEventListener("click", () => {
2405	            SGPBPopup.playMusic(e);
2406	            pbsgsoundnotification.classList.add("fade");
2407	        });
2408	    }
2409	});
2410
2411	
2412
2413	sgAddEvent(window, 'sgpbDidClose', function(e) {
2414		var args = e.detail;
2415		var popupId = parseInt(args.popupId);
2416		if (typeof window.SGPB_SOUND[popupId] && window.SGPB_SOUND[popupId]) {
2417			window.SGPB_SOUND[popupId].pause();
2418			delete window.SGPB_SOUND[popupId];
2419		}
2420	});
2421};
2422
2423SgpbEventListener.init = function()
2424{
2425	SgpbEventListener.eventsListenerAfterDocumentReady();
2426	var popupsData = jQuery('.sg-popup-builder-content');
2427
2428	if (!popupsData) {
2429		return '';
2430	}
2431
2432	var that = this;
2433
2434	popupsData.each(function() {
2435		var popupObj = that.popupObjCreator(jQuery(this));
2436		SGPBPopup.floatingButton(popupObj);
2437	});
2438};
2439
2440SgpbEventListener.popupObjCreator = function(currentData)
2441{
2442	var popupId = currentData.data('id');
2443	var popupData = currentData.data('options');
2444
2445	var events = currentData.attr('data-events');
2446	events = jQuery.parseJSON(events);
2447
2448	SgpbEventListener.reopenAfterFormSubmission(popupData);
2449
2450	var popupObj = new SGPBPopup();
2451	popupObj.setPopupId(popupId);
2452	popupObj.setPopupData(popupData);
2453
2454	for (var i in events) {
2455		var obj = new this;
2456		obj.setPopupObj(popupObj);
2457		obj.eventListener(events[i]);
2458	}
2459
2460	return popupObj;
2461};
2462
2463SgpbEventListener.prototype.eventListener = function(eventData)
2464{
2465	if (eventData == null) {
2466		return '';
2467	}
2468	var event = '';
2469	if (typeof eventData == 'string') {
2470		event = eventData;
2471	}
2472	else if (typeof eventData.param != 'undefined') {
2473		event = eventData.param;
2474	}
2475
2476	if (!event) {
2477		return false;
2478	}
2479
2480	var popupObj = this.getPopupObj();
2481	var popupData = popupObj.getPopupData();
2482
2483	if (eventData.value == '') {
2484		eventData.value = popupData['sgpb-popup-delay'];
2485	}
2486
2487	var eventName = SGPBPopup.capitalizeFirstLetter(event);
2488
2489	eventName = 'sgpb'+eventName;
2490	popupObj.eventName = eventName;
2491
2492	var allowToOpen = popupObj.forceCheckCurrentPopupType(popupObj);
2493
2494	if (!allowToOpen) {
2495		return false;
2496	}
2497	try {
2498		eval('this.'+eventName)(this, eventData);
2499	}
2500	catch (err) {
2501		console.log(err)
2502	}
2503
2504};
2505
2506SgpbEventListener.reopenAfterFormSubmission = function(eventData)
2507{
2508	var popupId = SGPBPopup.getCookie('SGPBSubmissionReloadPopup');
2509	popupId = parseInt(popupId);
2510
2511	if (!popupId) {
2512		return false;
2513	}
2514	var popupObj = SGPBPopup.createPopupObjById(popupId);
2515	if (!popupObj) {
2516		return false;
2517	}
2518	var options = popupObj.getPopupData();
2519
2520	if (!options['sgpb-reopen-after-form-submission']) {
2521		return false;
2522	}
2523
2524	popupObj.prepareOpen();
2525	SGPBPopup.deleteCookie('SGPBSubmissionReloadPopup');
2526};
2527
2528SgpbEventListener.prototype.sgpbLoad = function(listenerObj, eventData)
2529{
2530	var timeout = parseInt(eventData.value);
2531	var popupObj = listenerObj.getPopupObj();
2532	var popupOptions = popupObj.getPopupData();
2533	timeout *= 1000;
2534	var timerId,
2535		repetitiveTimeout = null;
2536
2537
2538	/* same as checkCurrentPopupType(), but it fires ignoring any delay (etc. onload delay) */
2539	popupObj.forceCheckCurrentPopupType(popupObj);
2540
2541
2542	var openOnLoadPopup = function() {
2543		setTimeout(function() {
2544			jQuery(window).trigger('sgpbLoadEvent', popupOptions);
2545			popupObj.prepareOpen();
2546		}, timeout);
2547	};
2548	sgAddEvent(window, 'load', openOnLoadPopup(timeout, popupObj));
2549	sgAddEvent(window, 'sgpbDidOpen', function(e) {
2550		var args = e.detail;
2551		clearInterval(repetitiveTimeout);
2552	});
2553
2554	sgAddEvent(window, 'sgpbDidClose', function(e) {
2555		var args = e.detail;
2556		var options = popupObj.getPopupData();
2557		if (SGPBPopup.varToBool(eventData['repetitive'])) {
2558			var intervalTime = parseInt(eventData['value'])*1000;
2559			repetitiveTimeout = setInterval(function() {
2560				popupObj.prepareOpen();
2561			}, intervalTime);
2562		}
2563	});
2564};
2565
2566SgpbEventListener.prototype.timerIncrement = function(listenerObj , idleInterval)
2567{
2568	var lastActivity = SgpbEventListener.inactivityIdicator;
2569
2570	if (lastActivity == 0) {
2571		clearInterval(idleInterval);
2572		listenerObj.getPopupObj().prepareOpen();
2573	}
2574	SgpbEventListener.inactivityIdicator = 0;
2575};
2576
2577SgpbEventListener.prototype.sgpbInsideclick = function(listenerObj, eventData)
2578{
2579	sgAddEvent(window, 'sgpbDidOpen', function(e) {
2580		var args = e.detail;
2581		var that = listenerObj;
2582		var popupObj = that.getPopupObj();
2583		var popupId = parseInt(popupObj.id);
2584		var targetClick = jQuery('.sgpb-content .sgpb-popup-id-'+popupId);
2585
2586		if (!targetClick.length) {
2587			return false;
2588		}
2589
2590		targetClick.each(function() {
2591			jQuery(this).unbind('click').bind('click', function() {
2592				var dontCloseCurrentPopup = jQuery(this).attr('dontCloseCurrentPopup');
2593				if (typeof dontCloseCurrentPopup == 'undefined' || dontCloseCurrentPopup != 'on') {
2594					SGPBPopup.closePopup();
2595				}
2596				popupObj.prepareOpen();
2597			});
2598		});
2599	});
2600};
2601
2602SgpbEventListener.prototype.sgpbClick = function(listenerObj, eventData)
2603{
2604	var that = listenerObj;
2605	var popupIds = [];
2606	var popupObj = that.getPopupObj();
2607	var popupOptions = popupObj.getPopupData();
2608	var popupId = parseInt(popupObj.id);
2609	popupIds.push(popupId);
2610	var mapId = listenerObj.filterPopupId(popupId);
2611	popupIds.push(mapId);
2612	if (jQuery.inArray(mapId, popupIds) === -1) {
2613		popupIds.push(mapId);
2614	}
2615
2616	for(var key in popupIds) {
2617		var popupId = popupIds[key];
2618		if (!popupIds.hasOwnProperty(key)) {
2619			return false;
2620		}
2621		var targetClick = jQuery('a[href*="#sg-popup-id-' + popupId + '"], .sg-popup-id-' + popupId + ', .sgpb-popup-id-' + popupId);
2622
2623		if (typeof eventData.operator != 'undefined' && eventData.operator == 'clickActionCustomClass') {
2624			targetClick = jQuery('a[href*="#sg-popup-id-' + popupId + '"], .sg-popup-id-' + popupId + ', .sgpb-popup-id-' + popupId+', .'+eventData.value);
2625		}
2626		if (!targetClick.length) {
2627			continue;
2628		}
2629		var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
2630		var clickCount = 1;
2631		targetClick.each(function() {
2632
2633			if (!jQuery(this).attr('data-popup-id')) {
2634				jQuery(this).attr('data-popup-id', popupId);
2635			}
2636			var currentTarget = jQuery(this);
2637			currentTarget.bind('swipe', function(e) {
2638				return false;
2639			});
2640			currentTarget.bind('click', function(e) {
2641				if (clickCount > 1) {
2642					return true;
2643				}
2644
2645				var allowToOpen = popupObj.forceCheckCurrentPopupType(popupObj);
2646				if (!allowToOpen) {
2647					return true;
2648				}
2649				++clickCount;
2650				jQuery(window).trigger('sgpbClickEvent', popupOptions);
2651				var popupId = jQuery(this).data('popup-id');
2652				setTimeout(function() {
2653
2654					var popupObj = SGPBPopup.createPopupObjById(popupId);
2655					if (!popupObj) {
2656						var mapId = listenerObj.filterPopupId(popupId);
2657						popupObj = SGPBPopup.createPopupObjById(mapId);
2658					}
2659					popupObj.customEvent = 'Click';
2660					popupObj.prepareOpen();
2661					clickCount = 1;
2662				}, delay);
2663
2664				return false;
2665			});
2666		});
2667	}
2668};
2669
2670SgpbEventListener.prototype.sgpbHover = function(listenerObj, eventData)
2671{
2672	var that = listenerObj;
2673	var popupObj = that.getPopupObj();
2674
2675	if (!popupObj) {
2676		return false;
2677	}
2678	var popupIds = [];
2679	var popupOptions = popupObj.getPopupData();
2680	var popupId = parseInt(popupObj.id);
2681	popupIds.push(popupId);
2682	var mapId = listenerObj.filterPopupId(popupId);
2683	if (jQuery.inArray(mapId, popupIds) === -1) {
2684		popupIds.push(mapId);
2685	}
2686
2687	for(var key in popupIds) {
2688		var popupId = popupIds[key];
2689		if (!popupIds.hasOwnProperty(key)) {
2690			return false;
2691		}
2692
2693		var hoverSelector = jQuery('.sg-popup-hover-' + popupId + ', .sgpb-popup-id-' + popupId + '[data-popup-event="hover"]');
2694
2695		if (typeof eventData.operator != 'undefined' && eventData.operator == 'hoverActionCustomClass') {
2696			hoverSelector = jQuery('.sg-popup-hover-' + popupId + ', .sgpb-popup-id-' + popupId + '[data-popup-event="hover"]'+', .'+eventData.value);
2697		}
2698
2699		if (!hoverSelector) {
2700			return false;
2701		}
2702		var hoverCount = 1;
2703		var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
2704
2705		hoverSelector.each(function () {
2706			if (!jQuery(this).attr('data-popup-id')) {
2707				jQuery(this).attr('data-popup-id', popupId);
2708			}
2709			jQuery(this).bind('mouseenter', function() {
2710				if (hoverCount > 1) {
2711					return false;
2712				}
2713				++hoverCount;
2714				var popupId = jQuery(this).data('popup-id');
2715				jQuery(window).trigger('sgpbHoverEvent', popupOptions);
2716				setTimeout(function() {
2717					var popupObj = SGPBPopup.createPopupObjById(popupId);
2718					if (!popupObj) {
2719						var mapId = listenerObj.filterPopupId(popupId);
2720						popupObj = SGPBPopup.createPopupObjById(mapId);
2721					}
2722					popupObj.customEvent = 'Hover';
2723					popupObj.prepareOpen();
2724					hoverCount = 1;
2725				}, delay);
2726			});
2727		});
2728	}
2729};
2730
2731SgpbEventListener.prototype.sgpbConfirm = function(listenerObj, eventData)
2732{
2733	var that = listenerObj;
2734	var popupObj = that.getPopupObj();
2735
2736	if (!popupObj) {
2737		return false;
2738	}
2739	var popupIds = [];
2740	var popupOptions = popupObj.getPopupData();
2741	var popupId = parseInt(popupObj.id);
2742	popupIds.push(popupId);
2743	var mapId = listenerObj.filterPopupId(popupId);
2744	popupIds.push(mapId);
2745
2746	for(var key in popupIds) {
2747		var popupId = popupIds[key];
2748		if (!popupIds.hasOwnProperty(key)) {
2749			return false;
2750		}
2751
2752		var confirmSelector = jQuery('.sg-confirm-popup-' + popupId);
2753
2754		if (!confirmSelector) {
2755			return false;
2756		}
2757		var confirmCount = 1;
2758
2759		confirmSelector.bind('click', function(e) {
2760			if (confirmCount > 1) {
2761				return false;
2762			}
2763			++confirmCount;
2764			var allowToOpen = popupObj.forceCheckCurrentPopupType(popupObj);
2765
2766			if (!allowToOpen) {
2767				return true;
2768			}
2769			jQuery(window).trigger('sgpbConfirmEvent', popupOptions);
2770			var target = jQuery(this).attr('target');
2771
2772			if (typeof target == 'undefined') {
2773				target = 'self';
2774			}
2775			var href = jQuery(this).attr('href');
2776			var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
2777			setTimeout(function() {
2778				if (typeof href != 'undefined') {
2779					popupOptions['sgpb-confirm-' + popupId] = {'target' : target, 'href' : href};
2780					popupObj.setPopupData(popupOptions);
2781				}
2782				popupObj.prepareOpen();
2783				confirmCount = 1;
2784			}, delay);
2785
2786			return false;
2787		});
2788
2789		sgAddEvent(window, 'sgpbDidClose', function(e) {
2790			var args = e.detail;
2791			var popupId = parseInt(args.popupId);
2792			var popupOptions = args.popupData;
2793
2794			if (typeof popupOptions['sgpb-confirm-' + popupId] != 'undefined') {
2795				var confirmAgrs = popupOptions['sgpb-confirm-' + popupId];
2796
2797				if (confirmAgrs['target'] == '_blank') {
2798					window.open(confirmAgrs['href']);
2799				}
2800				else {
2801					window.location.href = confirmAgrs['href'];
2802				}
2803
2804				delete popupOptions['sgpb-confirm-' + popupId];
2805				popupObj.setPopupData(popupOptions);
2806			}
2807		});
2808	}
2809};
2810
2811SgpbEventListener.prototype.sgpbAttronload = function(listenerObj, eventData)
2812{
2813	var that = listenerObj;
2814	var popupObj = that.getPopupObj();
2815	var popupId = parseInt(popupObj.id);
2816	popupId = listenerObj.filterPopupId(popupId);
2817	var popupOptions = popupObj.getPopupData();
2818	var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
2819	jQuery(window).trigger('sgpbAttronloadEvent', popupOptions);
2820
2821	setTimeout(function() {
2822		popupObj.prepareOpen();
2823	}, delay);
2824};
2825
2826/*for the old popups*/
2827SgpbEventListener.prototype.filterPopupId = function(popupId)
2828{
2829	var convertedIds = SGPB_POPUP_PARAMS.convertedIdsReverse;
2830	var popupNewId = popupId;
2831	if (convertedIds[popupId]) {
2832		return convertedIds[popupId];
2833	}
2834	else {
2835		for(var i in convertedIds) {
2836			if (popupId == convertedIds[i]) {
2837				popupNewId = parseInt(i);
2838				break;
2839			}
2840		}
2841	}
2842
2843	return popupNewId;
2844};
2845
2846SgpbEventListener.findCF7InPopup = function(popupId)
2847{
2848	return document.querySelector('#sg-popup-content-wrapper-'+popupId+' .wpcf7');
2849};
2850
2851SgpbEventListener.CF7EventListener = function(popupId, options)
2852{
2853	var wpcf7Elm = SgpbEventListener.findCF7InPopup(popupId);
2854
2855	if (wpcf7Elm) {
2856		wpcf7Elm.addEventListener('wpcf7mailsent', function(event) {
2857			var settings = {
2858				popupId: popupId,
2859				eventName: 'sgpbCF7Success'
2860			};
2861			jQuery(window).trigger('sgpbCF7Success', settings);
2862		});
2863	}
2864};
2865
2866SgpbEventListener.processCF7MailSent = function(popupId, options)
2867{
2868	var wpcf7Elm = SgpbEventListener.findCF7InPopup(popupId);
2869
2870	if (wpcf7Elm) {
2871		wpcf7Elm.addEventListener('wpcf7mailsent', function(event) {
2872			if (typeof options['operator'] == 'undefined') {
2873				return;
2874			}
2875			if (options['operator'] == 'close-popup') {
2876				setTimeout(function() {
2877					SGPBPopup.closePopupById(popupId);
2878				}, parseInt(options['value'])*1000);
2879			}
2880			else if (options['operator'] == 'redirect-url') {
2881				window.location.href = options['value'];
2882			}
2883			else if (options['operator'] == 'open-popup') {
2884				SGPBPopup.closePopupById(popupId);
2885				var popupObj = SGPBPopup.createPopupObjById(Object.keys(options['value'])[0]);
2886				popupObj.prepareOpen();
2887			}
2888		}, false);
2889	}
2890};
2891
2892jQuery(document).ready(function(e) {
2893	setTimeout(function(){
2894		SgpbEventListener.init();
2895		SGPBPopup.listeners();
2896	}, 1);
2897});
2898// source --> https://rafflesinternationalcollege.ac.th/wp-includes/js/jquery/ui/core.min.js?ver=1.13.3 
2899/*! jQuery UI - v1.13.3 - 2024-04-26
2900* https://jqueryui.com
2901* Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-patch.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js
2902* Copyright jQuery Foundation and other contributors; Licensed MIT */
2903!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(x){"use strict";var t,e,i,n,W,C,o,s,r,l,a,h,u;function E(t,e,i){return[parseFloat(t[0])*(a.test(t[0])?e/100:1),parseFloat(t[1])*(a.test(t[1])?i/100:1)]}function L(t,e){return parseInt(x.css(t,e),10)||0}function N(t){return null!=t&&t===t.window}x.ui=x.ui||{},x.ui.version="1.13.3",
2904/*!
2905 * jQuery UI :data 1.13.3
2906 * https://jqueryui.com
2907 *
2908 * Copyright OpenJS Foundation and other contributors
2909 * Released under the MIT license.
2910 * https://jquery.org/license
2911 */
2912x.extend(x.expr.pseudos,{data:x.expr.createPseudo?x.expr.createPseudo(function(e){return function(t){return!!x.data(t,e)}}):function(t,e,i){return!!x.data(t,i[3])}}),
2913/*!
2914 * jQuery UI Disable Selection 1.13.3
2915 * https://jqueryui.com
2916 *
2917 * Copyright OpenJS Foundation and other contributors
2918 * Released under the MIT license.
2919 * https://jquery.org/license
2920 */
2921x.fn.extend({disableSelection:(t="onselectstart"in document.createElement("div")?"selectstart":"mousedown",function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}),enableSelection:function(){return this.off(".ui-disableSelection")}}),
2922/*!
2923 * jQuery UI Focusable 1.13.3
2924 * https://jqueryui.com
2925 *
2926 * Copyright OpenJS Foundation and other contributors
2927 * Released under the MIT license.
2928 * https://jquery.org/license
2929 */
2930x.ui.focusable=function(t,e){var i,n,o,s=t.nodeName.toLowerCase();return"area"===s?(o=(i=t.parentNode).name,!(!t.href||!o||"map"!==i.nodeName.toLowerCase())&&0<(i=x("img[usemap='#"+o+"']")).length&&i.is(":visible")):(/^(input|select|textarea|button|object)$/.test(s)?(n=!t.disabled)&&(o=x(t).closest("fieldset")[0])&&(n=!o.disabled):n="a"===s&&t.href||e,n&&x(t).is(":visible")&&function(t){var e=t.css("visibility");for(;"inherit"===e;)t=t.parent(),e=t.css("visibility");return"visible"===e}(x(t)))},x.extend(x.expr.pseudos,{focusable:function(t){return x.ui.focusable(t,null!=x.attr(t,"tabindex"))}}),x.fn._form=function(){return"string"==typeof this[0].form?this.closest("form"):x(this[0].form)},
2931/*!
2932 * jQuery UI Form Reset Mixin 1.13.3
2933 * https://jqueryui.com
2934 *
2935 * Copyright OpenJS Foundation and other contributors
2936 * Released under the MIT license.
2937 * https://jquery.org/license
2938 */
2939x.ui.formResetMixin={_formResetHandler:function(){var e=x(this);setTimeout(function(){var t=e.data("ui-form-reset-instances");x.each(t,function(){this.refresh()})})},_bindFormResetHandler:function(){var t;this.form=this.element._form(),this.form.length&&((t=this.form.data("ui-form-reset-instances")||[]).length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t))},_unbindFormResetHandler:function(){var t;this.form.length&&((t=this.form.data("ui-form-reset-instances")).splice(
vendor: 15,096 bytes, lines 2939-3014
2939x.inArray(this,t),1),t.length?this.form.data("ui-form-reset-instances",t):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset"))}},x.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),
2940/*!
2941 * jQuery UI Support for jQuery core 1.8.x and newer 1.13.3
2942 * https://jqueryui.com
2943 *
2944 * Copyright OpenJS Foundation and other contributors
2945 * Released under the MIT license.
2946 * https://jquery.org/license
2947 *
2948 */
2949x.expr.pseudos||(x.expr.pseudos=x.expr[":"]),x.uniqueSort||(x.uniqueSort=x.unique),x.escapeSelector||(e=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g,i=function(t,e){return e?"\0"===t?"�":t.slice(0,-1)+"\\"+t.charCodeAt(t.length-1).toString(16)+" ":"\\"+t},x.escapeSelector=function(t){return(t+"").replace(e,i)}),x.fn.even&&x.fn.odd||x.fn.extend({even:function(){return this.filter(function(t){return t%2==0})},odd:function(){return this.filter(function(t){return t%2==1})}}),
2950/*!
2951 * jQuery UI Keycode 1.13.3
2952 * https://jqueryui.com
2953 *
2954 * Copyright OpenJS Foundation and other contributors
2955 * Released under the MIT license.
2956 * https://jquery.org/license
2957 */
2958x.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},
2959/*!
2960 * jQuery UI Labels 1.13.3
2961 * https://jqueryui.com
2962 *
2963 * Copyright OpenJS Foundation and other contributors
2964 * Released under the MIT license.
2965 * https://jquery.org/license
2966 */
2967x.fn.labels=function(){var t,e,i;return this.length?this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(e=this.eq(0).parents("label"),(t=this.attr("id"))&&(i=(i=this.eq(0).parents().last()).add((i.length?i:this).siblings()),t="label[for='"+x.escapeSelector(t)+"']",e=e.add(i.find(t).addBack(t))),this.pushStack(e)):this.pushStack([])},x.ui.plugin={add:function(t,e,i){var n,o=x.ui[t].prototype;for(n in i)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([e,i[n]])},call:function(t,e,i,n){var o,s=t.plugins[e];if(s&&(n||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(o=0;o<s.length;o++)t.options[s[o][0]]&&s[o][1].apply(t.element,i)}},
2968/*!
2969 * jQuery UI Position 1.13.3
2970 * https://jqueryui.com
2971 *
2972 * Copyright OpenJS Foundation and other contributors
2973 * Released under the MIT license.
2974 * https://jquery.org/license
2975 *
2976 * https://api.jqueryui.com/position/
2977 */
2978W=Math.max,C=Math.abs,o=/left|center|right/,s=/top|center|bottom/,r=/[\+\-]\d+(\.[\d]+)?%?/,l=/^\w+/,a=/%$/,h=x.fn.position,x.position={scrollbarWidth:function(){var t,e,i;return void 0!==n?n:(i=(e=x("<div style='display:block;position:absolute;width:200px;height:200px;overflow:hidden;'><div style='height:300px;width:auto;'></div></div>")).children()[0],x("body").append(e),t=i.offsetWidth,e.css("overflow","scroll"),t===(i=i.offsetWidth)&&(i=e[0].clientWidth),e.remove(),n=t-i)},getScrollInfo:function(t){var e=t.isWindow||t.isDocument?"":t.element.css("overflow-x"),i=t.isWindow||t.isDocument?"":t.element.css("overflow-y"),e="scroll"===e||"auto"===e&&t.width<t.element[0].scrollWidth;return{width:"scroll"===i||"auto"===i&&t.height<t.element[0].scrollHeight?x.position.scrollbarWidth():0,height:e?x.position.scrollbarWidth():0}},getWithinInfo:function(t){var e=x(t||window),i=N(e[0]),n=!!e[0]&&9===e[0].nodeType;return{element:e,isWindow:i,isDocument:n,offset:!i&&!n?x(t).offset():{left:0,top:0},scrollLeft:e.scrollLeft(),scrollTop:e.scrollTop(),width:e.outerWidth(),height:e.outerHeight()}}},x.fn.position=function(f){var c,d,p,g,m,v,y,w,b,_,t,e;return f&&f.of?(v="string"==typeof(f=x.extend({},f)).of?x(document).find(f.of):x(f.of),y=x.position.getWithinInfo(f.within),w=x.position.getScrollInfo(y),b=(f.collision||"flip").split(" "),_={},e=9===(e=(t=v)[0]).nodeType?{width:t.width(),height:t.height(),offset:{top:0,left:0}}:N(e)?{width:t.width(),height:t.height(),offset:{top:t.scrollTop(),left:t.scrollLeft()}}:e.preventDefault?{width:0,height:0,offset:{top:e.pageY,left:e.pageX}}:{width:t.outerWidth(),height:t.outerHeight(),offset:t.offset()},v[0].preventDefault&&(f.at="left top"),d=e.width,p=e.height,m=x.extend({},g=e.offset),x.each(["my","at"],function(){var t,e,i=(f[this]||"").split(" ");(i=1===i.length?o.test(i[0])?i.concat(["center"]):s.test(i[0])?["center"].concat(i):["center","center"]:i)[0]=o.test(i[0])?i[0]:"center",i[1]=s.test(i[1])?i[1]:"center",t=r.exec(i[0]),e=r.exec(i[1]),_[this]=[t?t[0]:0,e?e[0]:0],f[this]=[l.exec(i[0])[0],l.exec(i[1])[0]]}),1===b.length&&(b[1]=b[0]),"right"===f.at[0]?m.left+=d:"center"===f.at[0]&&(m.left+=d/2),"bottom"===f.at[1]?m.top+=p:"center"===f.at[1]&&(m.top+=p/2),c=E(_.at,d,p),m.left+=c[0],m.top+=c[1],this.each(function(){var i,t,r=x(this),l=r.outerWidth(),a=r.outerHeight(),e=L(this,"marginLeft"),n=L(this,"marginTop"),o=l+e+L(this,"marginRight")+w.width,s=a+n+L(this,"marginBottom")+w.height,h=x.extend({},m),u=E(_.my,r.outerWidth(),r.outerHeight());"right"===f.my[0]?h.left-=l:"center"===f.my[0]&&(h.left-=l/2),"bottom"===f.my[1]?h.top-=a:"center"===f.my[1]&&(h.top-=a/2),h.left+=u[0],h.top+=u[1],i={marginLeft:e,marginTop:n},x.each(["left","top"],function(t,e){x.ui.position[b[t]]&&x.ui.position[b[t]][e](h,{targetWidth:d,targetHeight:p,elemWidth:l,elemHeight:a,collisionPosition:i,collisionWidth:o,collisionHeight:s,offset:[c[0]+u[0],c[1]+u[1]],my:f.my,at:f.at,within:y,elem:r})}),f.using&&(t=function(t){var e=g.left-h.left,i=e+d-l,n=g.top-h.top,o=n+p-a,s={target:{element:v,left:g.left,top:g.top,width:d,height:p},element:{element:r,left:h.left,top:h.top,width:l,height:a},horizontal:i<0?"left":0<e?"right":"center",vertical:o<0?"top":0<n?"bottom":"middle"};d<l&&C(e+i)<d&&(s.horizontal="center"),p<a&&C(n+o)<p&&(s.vertical="middle"),W(C(e),C(i))>W(C(n),C(o))?s.important="horizontal":s.important="vertical",f.using.call(this,t,s)}),r.offset(x.extend(h,{using:t}))})):h.apply(this,arguments)},x.ui.position={fit:{left:function(t,e){var i,n=e.within,o=n.isWindow?n.scrollLeft:n.offset.left,n=n.width,s=t.left-e.collisionPosition.marginLeft,r=o-s,l=s+e.collisionWidth-n-o;n<e.collisionWidth?0<r&&l<=0?(i=t.left+r+e.collisionWidth-n-o,t.left+=r-i):t.left=!(0<l&&r<=0)&&l<r?o+n-e.collisionWidth:o:0<r?t.left+=r:0<l?t.left-=l:t.left=W(t.left-s,t.left)},top:function(t,e){var i,n=e.within,n=n.isWindow?n.scrollTop:n.offset.top,o=e.within.height,s=t.top-e.collisionPosition.marginTop,r=n-s,l=s+e.collisionHeight-o-n;o<e.collisionHeight?0<r&&l<=0?(i=t.top+r+e.collisionHeight-o-n,t.top+=r-i):t.top=!(0<l&&r<=0)&&l<r?n+o-e.collisionHeight:n:0<r?t.top+=r:0<l?t.top-=l:t.top=W(t.top-s,t.top)}},flip:{left:function(t,e){var i=e.within,n=i.offset.left+i.scrollLeft,o=i.width,i=i.isWindow?i.scrollLeft:i.offset.left,s=t.left-e.collisionPosition.marginLeft,r=s-i,s=s+e.collisionWidth-o-i,l="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,a="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,h=-2*e.offset[0];r<0?((o=t.left+l+a+h+e.collisionWidth-o-n)<0||o<C(r))&&(t.left+=l+a+h):0<s&&(0<(n=t.left-e.collisionPosition.marginLeft+l+a+h-i)||C(n)<s)&&(t.left+=l+a+h)},top:function(t,e){var i=e.within,n=i.offset.top+i.scrollTop,o=i.height,i=i.isWindow?i.scrollTop:i.offset.top,s=t.top-e.collisionPosition.marginTop,r=s-i,s=s+e.collisionHeight-o-i,l="top"===e.my[1]?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,a="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,h=-2*e.offset[1];r<0?((o=t.top+l+a+h+e.collisionHeight-o-n)<0||o<C(r))&&(t.top+=l+a+h):0<s&&(0<(n=t.top-e.collisionPosition.marginTop+l+a+h-i)||C(n)<s)&&(t.top+=l+a+h)}},flipfit:{left:function(){x.ui.position.flip.left.apply(this,arguments),x.ui.position.fit.left.apply(this,arguments)},top:function(){x.ui.position.flip.top.apply(this,arguments),x.ui.position.fit.top.apply(this,arguments)}}},x.ui.safeActiveElement=function(e){var i;try{i=e.activeElement}catch(t){i=e.body}return i=(i=i||e.body).nodeName?i:e.body},x.ui.safeBlur=function(t){t&&"body"!==t.nodeName.toLowerCase()&&x(t).trigger("blur")},
2979/*!
2980 * jQuery UI Scroll Parent 1.13.3
2981 * https://jqueryui.com
2982 *
2983 * Copyright OpenJS Foundation and other contributors
2984 * Released under the MIT license.
2985 * https://jquery.org/license
2986 */
2987x.fn.scrollParent=function(t){var e=this.css("position"),i="absolute"===e,n=t?/(auto|scroll|hidden)/:/(auto|scroll)/,t=this.parents().filter(function(){var t=x(this);return(!i||"static"!==t.css("position"))&&n.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return"fixed"!==e&&t.length?t:x(this[0].ownerDocument||document)},
2988/*!
2989 * jQuery UI Tabbable 1.13.3
2990 * https://jqueryui.com
2991 *
2992 * Copyright OpenJS Foundation and other contributors
2993 * Released under the MIT license.
2994 * https://jquery.org/license
2995 */
2996x.extend(x.expr.pseudos,{tabbable:function(t){var e=x.attr(t,"tabindex"),i=null!=e;return(!i||0<=e)&&x.ui.focusable(t,i)}}),
2997/*!
2998 * jQuery UI Unique ID 1.13.3
2999 * https://jqueryui.com
3000 *
3001 * Copyright OpenJS Foundation and other contributors
3002 * Released under the MIT license.
3003 * https://jquery.org/license
3004 */
3005x.fn.extend({uniqueId:(u=0,function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++u)})}),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&x(this).removeAttr("id")})}});
3006/*!
3007 * jQuery UI Widget 1.13.3
3008 * https://jqueryui.com
3009 *
3010 * Copyright OpenJS Foundation and other contributors
3011 * Released under the MIT license.
3012 * https://jquery.org/license
3013 */
3014var f,c=0,d=Array.prototype.hasOwnProperty,p=Array.prototype.slice;x.cleanData=(f=x.cleanData,function(t){for(var e,i,n=0;null!=(i=t[n]);n++)(e=x._data(i,"events"))&&e.remove&&x(i).triggerHandler("remove");f(t)}),x.widget=function(t,i,e){var n,o,s,r={},l=t.split(".")[0],a=l+"-"+(t=t.split(".")[1]);return e||(e=i,i=x.Widget),Array.isArray(e)&&(e=x.extend.apply(null,[{}].concat(e))),x.expr.pseudos[a.toLowerCase()]=function(t){return!!x.data(t,a)},x[l]=x[l]||{},n=x[l][t],o=x[l][t]=function(t,e){if(!this||!this._createWidget)return new o(t,e);arguments.length&&this._createWidget(t,e)},x.extend(o,n,{version:e.version,_proto:x.extend({},e),_childConstructors:[]}),(s=new i).options=x.widget.extend({},s.options),x.each(e,function(e,n){function o(){return i.prototype[e].apply(this,arguments)}function s(t){return i.prototype[e].apply(this,t)}r[e]="function"!=typeof n?n:function(){var t,e=this._super,i=this._superApply;return this._super=o,this._superApply=s,t=n.apply(this,arguments),this._super=e,this._superApply=i,t}}),o.prototype=x.widget.extend(s,{widgetEventPrefix:n&&s.widgetEventPrefix||t},r,{constructor:o,namespace:l,widgetName:t,widgetFullName:a}),n?(x.each(n._childConstructors,function(t,e){var i=e.prototype;x.widget(i.namespace+"."+i.widgetName,o,e._proto)}),delete n._childConstructors):i._childConstructors.push(o),x.widget.bridge(t,o),o},x.widget.extend=function(t){for(var e,i,n=p.call(arguments,1),o=0,s=n.length;o<s;o++)for(e in n[o])i=n[o][e],d.call(n[o],e)&&void 0!==i&&(x.isPlainObject(i)?t[e]=x.isPlainObject(t[e])?x.widget.extend({},t[e],i):x.widget.extend({},i):t[e]=i);return t},x.widget.bridge=function(s,e){var r=e.prototype.widgetFullName||s;x.fn[s]=function(i){var t="string"==typeof i,n=p.call(arguments,1),o=this;return t?this.length||"instance"!==i?this.each(function(){var t,e=x.data(this,r);return"instance"===i?(o=e,!1):e?"function"!=typeof e[i]||"_"===i.charAt(0)?x.error("no such method '"+i+"' for "+s+" widget instance"):(t=e[i].apply(e,n))!==e&&void 0!==t?(o=t&&t.jquery?o.pushStack(t.get()):t,!1):void 0:x.error("cannot call methods on "+s+" prior to initialization; attempted to call method '"+i+"'")}):o=void 0:(n.length&&(i=x.widget.extend.apply(null,[i].concat(n))),this.each(function(){var t=x.data(this,r);t?(t.option(i||{}),t._init&&t._init()):x.data(this,r,new e(i,this))})),o}},x.Widget=function(){},x.Widget._childConstructors=[],x.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{classes:{},disabled:!1,create:null},_createWidget:function(t,e){e=x(e||this.defaultElement||this)[0],this.element=x(e),this.uuid=c++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=x(),this.hoverable=x(),this.focusable=x(),this.classesElementLookup={},e!==this&&(x.data(e,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===e&&this.destroy()}}),this.document=x(e.style?e.ownerDocument:e.document||e),this.window=x(this.document[0].defaultView||this.document[0].parentWindow)),this.options=x.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:x.noop,_create:x.noop,_init:x.noop,destroy:function(){var i=this;this._destroy(),x.each(this.classesElementLookup,function(t,e){i._removeClass(e,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:x.noop,widget:function(){return this.element},option:function(t,e){var i,n,o,s=t;if(0===arguments.length)return x.widget.extend({},this.options);if("string"==typeof t)if(s={},t=(i=t.split(".")).shift(),i.length){for(n=s[t]=x.widget.extend({},this.options[t]),o=0;o<i.length-1;o++)n[i[o]]=n[i[o]]||{},n=n[i[o]];if(t=i.pop(),1===arguments.length)return void 0===n[t]?null:n[t];n[t]=e}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];s[t]=e}return this._setOptions(s),this},_setOptions:function(t){for(var e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(t){var e,i,n;for(e in t)n=this.classesElementLookup[e],t[e]!==this.options.classes[e]&&n&&n.length&&(i=x(n.get()),this._removeClass(n,e),i.addClass(this._classes({element:i,keys:e,classes:t,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(o){var s=[],r=this;function t(t,e){for(var i,n=0;n<t.length;n++)i=r.classesElementLookup[t[n]]||x(),i=o.add?(function(){var i=[];o.element.each(function(t,e){x.map(r.classesElementLookup,function(t){return t}).some(function(t){return t.is(e)})||i.push(e)}),r._on(x(i),{remove:"_untrackClassesElement"})}(),x(x.uniqueSort(i.get().concat(o.element.get())))):x(i.not(o.element).get()),r.classesElementLookup[t[n]]=i,s.push(t[n]),e&&o.classes[t[n]]&&s.push(o.classes[t[n]])}return(o=x.extend({element:this.element,classes:this.options.classes||{}},o)).keys&&t(o.keys.match(/\S+/g)||[],!0),o.extra&&t(o.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(i){var n=this;x.each(n.classesElementLookup,function(t,e){-1!==x.inArray(i.target,e)&&(n.classesElementLookup[t]=x(e.not(i.target).get()))}),this._off(x(i.target))}
vendor: 6,191 bytes, lines 3014-3024
3014,_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,n){var o="string"==typeof t||null===t,e={extra:o?e:i,keys:o?t:e,element:o?this.element:t,add:n="boolean"==typeof n?n:i};return e.element.toggleClass(this._classes(e),n),this},_on:function(o,s,t){var r,l=this;"boolean"!=typeof o&&(t=s,s=o,o=!1),t?(s=r=x(s),this.bindings=this.bindings.add(s)):(t=s,s=this.element,r=this.widget()),x.each(t,function(t,e){function i(){if(o||!0!==l.options.disabled&&!x(this).hasClass("ui-state-disabled"))return("string"==typeof e?l[e]:e).apply(l,arguments)}"string"!=typeof e&&(i.guid=e.guid=e.guid||i.guid||x.guid++);var t=t.match(/^([\w:-]*)\s*(.*)$/),n=t[1]+l.eventNamespace,t=t[2];t?r.on(n,t,i):s.on(n,i)})},_off:function(t,e){e=(e||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.off(e),this.bindings=x(this.bindings.not(t).get()),this.focusable=x(this.focusable.not(t).get()),this.hoverable=x(this.hoverable.not(t).get())},_delay:function(t,e){var i=this;return setTimeout(function(){return("string"==typeof t?i[t]:t).apply(i,arguments)},e||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){this._addClass(x(t.currentTarget),null,"ui-state-hover")},mouseleave:function(t){this._removeClass(x(t.currentTarget),null,"ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){this._addClass(x(t.currentTarget),null,"ui-state-focus")},focusout:function(t){this._removeClass(x(t.currentTarget),null,"ui-state-focus")}})},_trigger:function(t,e,i){var n,o,s=this.options[t];if(i=i||{},(e=x.Event(e)).type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),e.target=this.element[0],o=e.originalEvent)for(n in o)n in e||(e[n]=o[n]);return this.element.trigger(e,i),!("function"==typeof s&&!1===s.apply(this.element[0],[e].concat(i))||e.isDefaultPrevented())}},x.each({show:"fadeIn",hide:"fadeOut"},function(s,r){x.Widget.prototype["_"+s]=function(e,t,i){var n,o=(t="string"==typeof t?{effect:t}:t)?!0!==t&&"number"!=typeof t&&t.effect||r:s;"number"==typeof(t=t||{})?t={duration:t}:!0===t&&(t={}),n=!x.isEmptyObject(t),t.complete=i,t.delay&&e.delay(t.delay),n&&x.effects&&x.effects.effect[o]?e[s](t):o!==s&&e[o]?e[o](t.duration,t.easing,i):e.queue(function(t){x(this)[s](),i&&i.call(e[0]),t()})}})});
3015// source --> https://rafflesinternationalcollege.ac.th/wp-includes/js/jquery/ui/datepicker.min.js?ver=1.13.3 
3016/*!
3017 * jQuery UI Datepicker 1.13.3
3018 * https://jqueryui.com
3019 *
3020 * Copyright OpenJS Foundation and other contributors
3021 * Released under the MIT license.
3022 * https://jquery.org/license
3023 */
3024!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","../version","../keycode"],e):e(jQuery)}(function(V){"use strict";var n;function e(){this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:"",selectMonthLabel:"Select month",selectYearLabel:"Select year"},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,onUpdateDatepicker:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},V.extend(this._defaults,this.regional[""]),this.regional.en=V.extend(!0,{},this.regional[""]),this.regional["en-US"]=V.extend(!0,{},this.regional.en),this.dpDiv=a(V("<div id='"+this._mainDivId+"' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"))}function a(e){var t="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return e.on("mouseout",t,function(){V(this).removeClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&V(this).removeClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&V(this).removeClass("ui-datepicker-next-hover")}).on("mouseover",t,d)}function d(){V.datepicker._isDisabledDatepicker((n.inline?n.dpDiv.parent():n.input)[0])||(V(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),V(this).addClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&V(this).addClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&V(this).addClass("ui-datepicker-next-hover"))}function c(e,t){for(var a in V.extend(e,t),t)null==t[a]&&(e[a]=t[a])}return V.extend(V.ui,{datepicker:{version:"1.13.3"}}),V.extend(e.prototype,{markerClassName:"hasDatepicker",maxRows:4,_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(e){return c(this._defaults,e||{}),this},_attachDatepicker:function(e,t){var a,i=e.nodeName.toLowerCase(),s="div"===i||"span"===i;
vendor: 32,551 bytes, line 3024
3024e.id||(this.uuid+=1,e.id="dp"+this.uuid),(a=this._newInst(V(e),s)).settings=V.extend({},t||{}),"input"===i?this._connectDatepicker(e,a):s&&this._inlineDatepicker(e,a)},_newInst:function(e,t){return{id:e[0].id.replace(/([^A-Za-z0-9_\-])/g,"\\\\$1"),input:e,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:t,dpDiv:t?a(V("<div class='"+this._inlineClass+" ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")):this.dpDiv}},_connectDatepicker:function(e,t){var a=V(e);t.append=V([]),t.trigger=V([]),a.hasClass(this.markerClassName)||(this._attachments(a,t),a.addClass(this.markerClassName).on("keydown",this._doKeyDown).on("keypress",this._doKeyPress).on("keyup",this._doKeyUp),this._autoSize(t),V.data(e,"datepicker",t),t.settings.disabled&&this._disableDatepicker(e))},_attachments:function(e,t){var a,i=this._get(t,"appendText"),s=this._get(t,"isRTL");t.append&&t.append.remove(),i&&(t.append=V("<span>").addClass(this._appendClass).text(i),e[s?"before":"after"](t.append)),e.off("focus",this._showDatepicker),t.trigger&&t.trigger.remove(),"focus"!==(i=this._get(t,"showOn"))&&"both"!==i||e.on("focus",this._showDatepicker),"button"!==i&&"both"!==i||(i=this._get(t,"buttonText"),a=this._get(t,"buttonImage"),this._get(t,"buttonImageOnly")?t.trigger=V("<img>").addClass(this._triggerClass).attr({src:a,alt:i,title:i}):(t.trigger=V("<button type='button'>").addClass(this._triggerClass),a?t.trigger.html(V("<img>").attr({src:a,alt:i,title:i})):t.trigger.text(i)),e[s?"before":"after"](t.trigger),t.trigger.on("click",function(){return V.datepicker._datepickerShowing&&V.datepicker._lastInput===e[0]?V.datepicker._hideDatepicker():(V.datepicker._datepickerShowing&&V.datepicker._lastInput!==e[0]&&V.datepicker._hideDatepicker(),V.datepicker._showDatepicker(e[0])),!1}))},_autoSize:function(e){var t,a,i,s,r,n;this._get(e,"autoSize")&&!e.inline&&(r=new Date(2009,11,20),(n=this._get(e,"dateFormat")).match(/[DM]/)&&(r.setMonth((t=function(e){for(s=i=a=0;s<e.length;s++)e[s].length>a&&(a=e[s].length,i=s);return i})(this._get(e,n.match(/MM/)?"monthNames":"monthNamesShort"))),r.setDate(t(this._get(e,n.match(/DD/)?"dayNames":"dayNamesShort"))+20-r.getDay())),e.input.attr("size",this._formatDate(e,r).length))},_inlineDatepicker:function(e,t){var a=V(e);a.hasClass(this.markerClassName)||(a.addClass(this.markerClassName).append(t.dpDiv),V.data(e,"datepicker",t),this._setDate(t,this._getDefaultDate(t),!0),this._updateDatepicker(t),this._updateAlternate(t),t.settings.disabled&&this._disableDatepicker(e),t.dpDiv.css("display","block"))},_dialogDatepicker:function(e,t,a,i,s){var r,n=this._dialogInst;return n||(this.uuid+=1,r="dp"+this.uuid,this._dialogInput=V("<input type='text' id='"+r+"' style='position: absolute; top: -100px; width: 0px;'/>"),this._dialogInput.on("keydown",this._doKeyDown),V("body").append(this._dialogInput),(n=this._dialogInst=this._newInst(this._dialogInput,!1)).settings={},V.data(this._dialogInput[0],"datepicker",n)),c(n.settings,i||{}),t=t&&t.constructor===Date?this._formatDate(n,t):t,this._dialogInput.val(t),this._pos=s?s.length?s:[s.pageX,s.pageY]:null,this._pos||(r=document.documentElement.clientWidth,i=document.documentElement.clientHeight,t=document.documentElement.scrollLeft||document.body.scrollLeft,s=document.documentElement.scrollTop||document.body.scrollTop,this._pos=[r/2-100+t,i/2-150+s]),this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),n.settings.onSelect=a,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),V.blockUI&&V.blockUI(this.dpDiv),V.data(this._dialogInput[0],"datepicker",n),this},_destroyDatepicker:function(e){var t,a=V(e),i=V.data(e,"datepicker");a.hasClass(this.markerClassName)&&(t=e.nodeName.toLowerCase(),V.removeData(e,"datepicker"),"input"===t?(i.append.remove(),i.trigger.remove(),a.removeClass(this.markerClassName).off("focus",this._showDatepicker).off("keydown",this._doKeyDown).off("keypress",this._doKeyPress).off("keyup",this._doKeyUp)):"div"!==t&&"span"!==t||a.removeClass(this.markerClassName).empty(),n===i)&&(n=null,this._curInst=null)},_enableDatepicker:function(t){var e,a=V(t),i=V.data(t,"datepicker");a.hasClass(this.markerClassName)&&("input"===(e=t.nodeName.toLowerCase())?(t.disabled=!1,i.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""})):"div"!==e&&"span"!==e||((i=a.children("."+this._inlineClass)).children().removeClass("ui-state-disabled"),i.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!1)),this._disabledInputs=V.map(this._disabledInputs,function(e){return e===t?null:e}))},_disableDatepicker:function(t){var e,a=V(t),i=V.data(t,"datepicker");a.hasClass(this.markerClassName)&&("input"===(e=t.nodeName.toLowerCase())?(t.disabled=!0,i.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"})):"div"!==e&&"span"!==e||((i=a.children("."+this._inlineClass)).children().addClass("ui-state-disabled"),i.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!0)),this._disabledInputs=V.map(this._disabledInputs,function(e){return e===t?null:e}),this._disabledInputs[this._disabledInputs.length]=t)},_isDisabledDatepicker:function(e){if(e)for(var t=0;t<this._disabledInputs.length;t++)if(this._disabledInputs[t]===e)return!0;return!1},_getInst:function(e){try{return V.data(e,"datepicker")}catch(e){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(e,t,a){var i,s,r=this._getInst(e);if(2===arguments.length&&"string"==typeof t)return"defaults"===t?V.extend({},V.datepicker._defaults):r?"all"===t?V.extend({},r.settings):this._get(r,t):null;i=t||{},"string"==typeof t&&((i={})[t]=a),r&&(this._curInst===r&&this._hideDatepicker(),t=this._getDateDatepicker(e,!0),a=this._getMinMaxDate(r,"min"),s=this._getMinMaxDate(r,"max"),c(r.settings,i),null!==a&&void 0!==i.dateFormat&&void 0===i.minDate&&(r.settings.minDate=this._formatDate(r,a)),null!==s&&void 0!==i.dateFormat&&void 0===i.maxDate&&(r.settings.maxDate=this._formatDate(r,s)),"disabled"in i&&(i.disabled?this._disableDatepicker(e):this._enableDatepicker(e)),this._attachments(V(e),r),this._autoSize(r),this._setDate(r,t),this._updateAlternate(r),this._updateDatepicker(r))},_changeDatepicker:function(e,t,a){this._optionDatepicker(e,t,a)},_refreshDatepicker:function(e){e=this._getInst(e);e&&this._updateDatepicker(e)},_setDateDatepicker:function(e,t){e=this._getInst(e);e&&(this._setDate(e,t),this._updateDatepicker(e),this._updateAlternate(e))},_getDateDatepicker:function(e,t){e=this._getInst(e);return e&&!e.inline&&this._setDateFromField(e,t),e?this._getDate(e):null},_doKeyDown:function(e){var t,a,i=V.datepicker._getInst(e.target),s=!0,r=i.dpDiv.is(".ui-datepicker-rtl");if(i._keyEvent=!0,V.datepicker._datepickerShowing)switch(e.keyCode){case 9:V.datepicker._hideDatepicker(),s=!1;break;case 13:return(a=V("td."+V.datepicker._dayOverClass+":not(."+V.datepicker._currentClass+")",i.dpDiv))[0]&&V.datepicker._selectDay(e.target,i.selectedMonth,i.selectedYear,a[0]),(a=V.datepicker._get(i,"onSelect"))?(t=V.datepicker._formatDate(i),a.apply(i.input?i.input[0]:null,[t,i])):V.datepicker._hideDatepicker(),!1;case 27:V.datepicker._hideDatepicker();break;case 33:V.datepicker._adjustDate(e.target,e.ctrlKey?-V.datepicker._get(i,"stepBigMonths"):-V.datepicker._get(i,"stepMonths"),"M");break;case 34:V.datepicker._adjustDate(e.target,e.ctrlKey?+V.datepicker._get(i,"stepBigMonths"):+V.datepicker._get(i,"stepMonths"),"M");break;case 35:(e.ctrlKey||e.metaKey)&&V.datepicker._clearDate(e.target),s=e.ctrlKey||e.metaKey;break;case 36:(e.ctrlKey||e.metaKey)&&V.datepicker._gotoToday(e.target),s=e.ctrlKey||e.metaKey;break;case 37:(e.ctrlKey||e.metaKey)&&V.datepicker._adjustDate(e.target,r?1:-1,"D"),s=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&V.datepicker._adjustDate(e.target,e.ctrlKey?-V.datepicker._get(i,"stepBigMonths"):-V.datepicker._get(i,"stepMonths"),"M");break;case 38:(e.ctrlKey||e.metaKey)&&V.datepicker._adjustDate(e.target,-7,"D"),s=e.ctrlKey||e.metaKey;break;case 39:(e.ctrlKey||e.metaKey)&&V.datepicker._adjustDate(e.target,r?-1:1,"D"),s=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&V.datepicker._adjustDate(e.target,e.ctrlKey?+V.datepicker._get(i,"stepBigMonths"):+V.datepicker._get(i,"stepMonths"),"M");break;case 40:(e.ctrlKey||e.metaKey)&&V.datepicker._adjustDate(e.target,7,"D"),s=e.ctrlKey||e.metaKey;break;default:s=!1}else 36===e.keyCode&&e.ctrlKey?V.datepicker._showDatepicker(this):s=!1;s&&(e.preventDefault(),e.stopPropagation())},_doKeyPress:function(e){var t,a=V.datepicker._getInst(e.target);if(V.datepicker._get(a,"constrainInput"))return a=V.datepicker._possibleChars(V.datepicker._get(a,"dateFormat")),t=String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),e.ctrlKey||e.metaKey||t<" "||!a||-1<a.indexOf(t)},_doKeyUp:function(e){e=V.datepicker._getInst(e.target);if(e.input.val()!==e.lastVal)try{V.datepicker.parseDate(V.datepicker._get(e,"dateFormat"),e.input?e.input.val():null,V.datepicker._getFormatConfig(e))&&(V.datepicker._setDateFromField(e),V.datepicker._updateAlternate(e),V.datepicker._updateDatepicker(e))}catch(e){}return!0},_showDatepicker:function(e){var t,a,i,s;"input"!==(e=e.target||e).nodeName.toLowerCase()&&(e=V("input",e.parentNode)[0]),V.datepicker._isDisabledDatepicker(e)||V.datepicker._lastInput===e||(s=V.datepicker._getInst(e),V.datepicker._curInst&&V.datepicker._curInst!==s&&(V.datepicker._curInst.dpDiv.stop(!0,!0),s)&&V.datepicker._datepickerShowing&&V.datepicker._hideDatepicker(V.datepicker._curInst.input[0]),!1===(a=(a=V.datepicker._get(s,"beforeShow"))?a.apply(e,[e,s]):{}))||(c(s.settings,a),s.lastVal=null,V.datepicker._lastInput=e,V.datepicker._setDateFromField(s),V.datepicker._inDialog&&(e.value=""),V.datepicker._pos||(V.datepicker._pos=V.datepicker._findPos(e),V.datepicker._pos[1]+=e.offsetHeight),t=!1,V(e).parents().each(function(){return!(t|="fixed"===V(this).css("position"))}),a={left:V.datepicker._pos[0],top:V.datepicker._pos[1]},V.datepicker._pos=null,s.dpDiv.empty(),s.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),V.datepicker._updateDatepicker(s),a=V.datepicker._checkOffset(s,a,t),s.dpDiv.css({position:V.datepicker._inDialog&&V.blockUI?"static":t?"fixed":"absolute",display:"none",left:a.left+"px",top:a.top+"px"}),s.inline)||(a=V.datepicker._get(s,"showAnim"),i=V.datepicker._get(s,"duration"),s.dpDiv.css("z-index",function(e){for(var t;e.length&&e[0]!==document;){if(("absolute"===(t=e.css("position"))||"relative"===t||"fixed"===t)&&(t=parseInt(e.css("zIndex"),10),!isNaN(t))&&0!==t)return t;e=e.parent()}return 0}(V(e))+1),V.datepicker._datepickerShowing=!0,V.effects&&V.effects.effect[a]?s.dpDiv.show(a,V.datepicker._get(s,"showOptions"),i):s.dpDiv[a||"show"](a?i:null),V.datepicker._shouldFocusInput(s)&&s.input.trigger("focus"),V.datepicker._curInst=s)},_updateDatepicker:function(e){this.maxRows=4,(n=e).dpDiv.empty().append(this._generateHTML(e)),this._attachHandlers(e);var t,a=this._getNumberOfMonths(e),i=a[1],s=e.dpDiv.find("."+this._dayOverClass+" a"),r=V.datepicker._get(e,"onUpdateDatepicker");0<s.length&&d.apply(s.get(0)),e.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),1<i&&e.dpDiv.addClass("ui-datepicker-multi-"+i).css("width",17*i+"em"),e.dpDiv[(1!==a[0]||1!==a[1]?"add":"remove")+"Class"]("ui-datepicker-multi"),e.dpDiv[(this._get(e,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),e===V.datepicker._curInst&&V.datepicker._datepickerShowing&&V.datepicker._shouldFocusInput(e)&&e.input.trigger("focus"),e.yearshtml&&(t=e.yearshtml,setTimeout(function(){t===e.yearshtml&&e.yearshtml&&e.dpDiv.find("select.ui-datepicker-year").first().replaceWith(e.yearshtml),t=e.yearshtml=null},0)),r&&r.apply(e.input?e.input[0]:null,[e])},_shouldFocusInput:function(e){return e.input&&e.input.is(":visible")&&!e.input.is(":disabled")&&!e.input.is(":focus")},_checkOffset:function(e,t,a){var i=e.dpDiv.outerWidth(),s=e.dpDiv.outerHeight(),r=e.input?e.input.outerWidth():0,n=e.input?e.input.outerHeight():0,d=document.documentElement.clientWidth+(a?0:V(document).scrollLeft()),c=document.documentElement.clientHeight+(a?0:V(document).scrollTop());return t.left-=this._get(e,"isRTL")?i-r:0,t.left-=a&&t.left===e.input.offset().left?V(document).scrollLeft():0,t.top-=a&&t.top===e.input.offset().top+n?V(document).scrollTop():0,t.left-=Math.min(t.left,d<t.left+i&&i<d?Math.abs(t.left+i-d):0),t.top-=Math.min(t.top,c<t.top+s&&s<c?Math.abs(s+n):0),t},_findPos:function(e){for(var t=this._getInst(e),a=this._get(t,"isRTL");e&&("hidden"===e.type||1!==e.nodeType||V.expr.pseudos.hidden(e));)e=e[a?"previousSibling":"nextSibling"];return[(t=V(e).offset()).left,t.top]},_hideDatepicker:function(e){var t,a,i=this._curInst;!i||e&&i!==V.data(e,"datepicker")||this._datepickerShowing&&(e=this._get(i,"showAnim"),a=this._get(i,"duration"),t=function(){V.datepicker._tidyDialog(i)},V.effects&&(V.effects.effect[e]||V.effects[e])?i.dpDiv.hide(e,V.datepicker._get(i,"showOptions"),a,t):i.dpDiv["slideDown"===e?"slideUp":"fadeIn"===e?"fadeOut":"hide"](e?a:null,t),e||t(),this._datepickerShowing=!1,(a=this._get(i,"onClose"))&&a.apply(i.input?i.input[0]:null,[i.input?i.input.val():"",i]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),V.blockUI)&&(V.unblockUI(),V("body").append(this.dpDiv)),this._inDialog=!1)},_tidyDialog:function(e){e.dpDiv.removeClass(this._dialogClass).off(".ui-datepicker-calendar")},_checkExternalClick:function(e){var t;V.datepicker._curInst&&(e=V(e.target),t=V.datepicker._getInst(e[0]),!(e[0].id===V.datepicker._mainDivId||0!==e.parents("#"+V.datepicker._mainDivId).length||e.hasClass(V.datepicker.markerClassName)||e.closest("."+V.datepicker._triggerClass).length||!V.datepicker._datepickerShowing||V.datepicker._inDialog&&V.blockUI)||e.hasClass(V.datepicker.markerClassName)&&V.datepicker._curInst!==t)&&V.datepicker._hideDatepicker()},_adjustDate:function(e,t,a){var e=V(e),i=this._getInst(e[0]);this._isDisabledDatepicker(e[0])||(this._adjustInstDate(i,t,a),this._updateDatepicker(i))},_gotoToday:function(e){var t,e=V(e),a=this._getInst(e[0]);this._get(a,"gotoCurrent")&&a.currentDay?(a.selectedDay=a.currentDay,a.drawMonth=a.selectedMonth=a.currentMonth,a.drawYear=a.selectedYear=a.currentYear):(t=new Date,a.selectedDay=t.getDate(),a.drawMonth=a.selectedMonth=t.getMonth(),a.drawYear=a.selectedYear=t.getFullYear()),this._notifyChange(a),this._adjustDate(e)},_selectMonthYear:function(e,t,a){var e=V(e),i=this._getInst(e[0]);i["selected"+("M"===a?"Month":"Year")]=i["draw"+("M"===a?"Month":"Year")]=parseInt(t.options[t.selectedIndex].value,10),this._notifyChange(i),this._adjustDate(e)},_selectDay:function(e,t,a,i){var s=V(e);V(i).hasClass(this._unselectableClass)||this._isDisabledDatepicker(s[0])||((s=this._getInst(s[0])).selectedDay=s.currentDay=parseInt(V("a",i).attr("data-date")),s.selectedMonth=s.currentMonth=t,s.selectedYear=s.currentYear=a,this._selectDate(e,this._formatDate(s,s.currentDay,s.currentMonth,s.currentYear)))},_clearDate:function(e){e=V(e);this._selectDate(e,"")},_selectDate:function(e,t){var a,e=V(e),e=this._getInst(e[0]);t=null!=t?t:this._formatDate(e),e.input&&e.input.val(t),this._updateAlternate(e),(a=this._get(e,"onSelect"))?a.apply(e.input?e.input[0]:null,[t,e]):e.input&&e.input.trigger("change"),e.inline?this._updateDatepicker(e):(this._hideDatepicker(),this._lastInput=e.input[0],"object"!=typeof e.input[0]&&e.input.trigger("focus"),this._lastInput=null)},_updateAlternate:function(e){var t,a,i=this._get(e,"altField");i&&(a=this._get(e,"altFormat")||this._get(e,"dateFormat"),t=this._getDate(e),a=this.formatDate(a,t,this._getFormatConfig(e)),V(document).find(i).val(a))},noWeekends:function(e){e=e.getDay();return[0<e&&e<6,""]},iso8601Week:function(e){var t,e=new Date(e.getTime());return e.setDate(e.getDate()+4-(e.getDay()||7)),t=e.getTime(),e.setMonth(0),e.setDate(1),Math.floor(Math.round((t-e)/864e5)/7)+1},parseDate:function(t,s,e){if(null==t||null==s)throw"Invalid arguments";if(""===(s="object"==typeof s?s.toString():s+""))return null;for(var a,i,r=0,n=(e?e.shortYearCutoff:null)||this._defaults.shortYearCutoff,n="string"!=typeof n?n:(new Date).getFullYear()%100+parseInt(n,10),d=(e?e.dayNamesShort:null)||this._defaults.dayNamesShort,c=(e?e.dayNames:null)||this._defaults.dayNames,o=(e?e.monthNamesShort:null)||this._defaults.monthNamesShort,l=(e?e.monthNames:null)||this._defaults.monthNames,h=-1,u=-1,p=-1,g=-1,_=!1,f=function(e){e=y+1<t.length&&t.charAt(y+1)===e;return e&&y++,e},k=function(e){var t=f(e),t="@"===e?14:"!"===e?20:"y"===e&&t?4:"o"===e?3:2,e=new RegExp("^\\d{"+("y"===e?t:1)+","+t+"}"),t=s.substring(r).match(e);if(t)return r+=t[0].length,parseInt(t[0],10);throw"Missing number at position "+r},D=function(e,t,a){var i=-1,e=V.map(f(e)?a:t,function(e,t){return[[t,e]]}).sort(function(e,t){return-(e[1].length-t[1].length)});if(V.each(e,function(e,t){var a=t[1];if(s.substr(r,a.length).toLowerCase()===a.toLowerCase())return i=t[0],r+=a.length,!1}),-1!==i)return i+1;throw"Unknown name at position "+r},m=function(){if(s.charAt(r)!==t.charAt(y))throw"Unexpected literal at position "+r;r++},y=0;y<t.length;y++)if(_)"'"!==t.charAt(y)||f("'")?m():_=!1;else switch(t.charAt(y)){case"d":p=k("d");break;case"D":D("D",d,c);break;case"o":g=k("o");break;case"m":u=k("m");break;case"M":u=D("M",o,l);break;case"y":h=k("y");break;case"@":h=(i=new Date(k("@"))).getFullYear(),u=i.getMonth()+1,p=i.getDate();break;case"!":h=(i=new Date((k("!")-this._ticksTo1970)/1e4)).getFullYear(),u=i.getMonth()+1,p=i.getDate();break;case"'":f("'")?m():_=!0;break;default:m()}if(r<s.length&&(e=s.substr(r),!/^\s+/.test(e)))throw"Extra/unparsed characters found in date: "+e;if(-1===h?h=(new Date).getFullYear():h<100&&(h+=(new Date).getFullYear()-(new Date).getFullYear()%100+(h<=n?0:-100)),-1<g)for(u=1,p=g;;){if(p<=(a=this._getDaysInMonth(h,u-1)))break;u++,p-=a}if((i=this._daylightSavingAdjust(new Date(h,u-1,p))).getFullYear()!==h||i.getMonth()+1!==u||i.getDate()!==p)throw"Invalid date";return i},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:24*(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*60*60*1e7,formatDate:function(t,e,a){if(!e)return"";function i(e,t,a){var i=""+t;if(l(e))for(;i.length<a;)i="0"+i;return i}function s(e,t,a,i){return(l(e)?i:a)[t]}var r,n=(a?a.dayNamesShort:null)||this._defaults.dayNamesShort,d=(a?a.dayNames:null)||this._defaults.dayNames,c=(a?a.monthNamesShort:null)||this._defaults.monthNamesShort,o=(a?a.monthNames:null)||this._defaults.monthNames,l=function(e){e=r+1<t.length&&t.charAt(r+1)===e;return e&&r++,e},h="",u=!1;if(e)for(r=0;r<t.length;r++)if(u)"'"!==t.charAt(r)||l("'")?h+=t.charAt(r):u=!1;else switch(t.charAt(r)){case"d":h+=i("d",e.getDate(),2);break;case"D":h+=s("D",e.getDay(),n,d);break;case"o":h+=i("o",Math.round((new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()-new Date(e.getFullYear(),0,0).getTime())/864e5),3);break;case"m":h+=i("m",e.getMonth()+1,2);break;case"M":h+=s("M",e.getMonth(),c,o);break;case"y":h+=l("y")?e.getFullYear():(e.getFullYear()%100<10?"0":"")+e.getFullYear()%100;break;case"@":h+=e.getTime();break;case"!":h+=1e4*e.getTime()+this._ticksTo1970;break;case"'":l("'")?h+="'":u=!0;break;default:h+=t.charAt(r)}return h},_possibleChars:function(t){for(var e="",a=!1,i=function(e){e=s+1<t.length&&t.charAt(s+1)===e;return e&&s++,e},s=0;s<t.length;s++)if(a)"'"!==t.charAt(s)||i("'")?e+=t.charAt(s):a=!1;else switch(t.charAt(s)){case"d":case"m":case"y":case"@":e+="0123456789";break;case"D":case"M":return null;case"'":i("'")?e+="'":a=!0;break;default:e+=t.charAt(s)}return e},_get:function(e,t){return(void 0!==e.settings[t]?e.settings:this._defaults)[t]},_setDateFromField:function(e,t){if(e.input.val()!==e.lastVal){var a=this._get(e,"dateFormat"),i=e.lastVal=e.input?e.input.val():null,s=this._getDefaultDate(e),r=s,n=this._getFormatConfig(e);try{r=this.parseDate(a,i,n)||s}catch(e){i=t?"":i}e.selectedDay=r.getDate(),e.drawMonth=e.selectedMonth=r.getMonth(),e.drawYear=e.selectedYear=r.getFullYear(),e.currentDay=i?r.getDate():0,e.currentMonth=i?r.getMonth():0,e.currentYear=i?r.getFullYear():0,this._adjustInstDate(e)}},_getDefaultDate:function(e){return this._restrictMinMax(e,this._determineDate(e,this._get(e,"defaultDate"),new Date))},_determineDate:function(d,e,t){var a,i=null==e||""===e?t:"string"==typeof e?function(e){try{return V.datepicker.parseDate(V.datepicker._get(d,"dateFormat"),e,V.datepicker._getFormatConfig(d))}catch(e){}for(var t=(e.toLowerCase().match(/^c/)?V.datepicker._getDate(d):null)||new Date,a=t.getFullYear(),i=t.getMonth(),s=t.getDate(),r=/([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,n=r.exec(e);n;){switch(n[2]||"d"){case"d":case"D":s+=parseInt(n[1],10);break;case"w":case"W":s+=7*parseInt(n[1],10);break;case"m":case"M":i+=parseInt(n[1],10),s=Math.min(s,V.datepicker._getDaysInMonth(a,i));break;case"y":case"Y":a+=parseInt(n[1],10),s=Math.min(s,V.datepicker._getDaysInMonth(a,i))}n=r.exec(e)}return new Date(a,i,s)}(e):"number"==typeof e?isNaN(e)?t:(i=e,(a=new Date).setDate(a.getDate()+i),a):new Date(e.getTime());return(i=i&&"Invalid Date"===i.toString()?t:i)&&(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0)),this._daylightSavingAdjust(i)},_daylightSavingAdjust:function(e){return e?(e.setHours(12<e.getHours()?e.getHours()+2:0),e):null},_setDate:function(e,t,a){var i=!t,s=e.selectedMonth,r=e.selectedYear,t=this._restrictMinMax(e,this._determineDate(e,t,new Date));e.selectedDay=e.currentDay=t.getDate(),e.drawMonth=e.selectedMonth=e.currentMonth=t.getMonth(),e.drawYear=e.selectedYear=e.currentYear=t.getFullYear(),s===e.selectedMonth&&r===e.selectedYear||a||this._notifyChange(e),this._adjustInstDate(e),e.input&&e.input.val(i?"":this._formatDate(e))},_getDate:function(e){return!e.currentYear||e.input&&""===e.input.val()?null:this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay))},_attachHandlers:function(e){var t=this._get(e,"stepMonths"),a="#"+e.id.replace(/\\\\/g,"\\");e.dpDiv.find("[data-handler]").map(function(){var e={prev:function(){V.datepicker._adjustDate(a,-t,"M")},next:function(){V.datepicker._adjustDate(a,+t,"M")},hide:function(){V.datepicker._hideDatepicker()},today:function(){V.datepicker._gotoToday(a)},selectDay:function(){return V.datepicker._selectDay(a,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return V.datepicker._selectMonthYear(a,this,"M"),!1},selectYear:function(){return V.datepicker._selectMonthYear(a,this,"Y"),!1}};V(this).on(this.getAttribute("data-event"),e[this.getAttribute("data-handler")])})},_generateHTML:function(e){var t,a,i,s,r,O,L,R,H,n,d,W,c,o,l,h,u,p,g,_,f,k,E,D,m,U,y,P,z,v,M,b,w=new Date,B=this._daylightSavingAdjust(new Date(w.getFullYear(),w.getMonth(),w.getDate())),C=this._get(e,"isRTL"),w=this._get(e,"showButtonPanel"),I=this._get(e,"hideIfNoPrevNext"),x=this._get(e,"navigationAsDateFormat"),Y=this._getNumberOfMonths(e),S=this._get(e,"showCurrentAtPos"),F=this._get(e,"stepMonths"),J=1!==Y[0]||1!==Y[1],N=this._daylightSavingAdjust(e.currentDay?new Date(e.currentYear,e.currentMonth,e.currentDay):new Date(9999,9,9)),T=this._getMinMaxDate(e,"min"),A=this._getMinMaxDate(e,"max"),K=e.drawMonth-S,j=e.drawYear;if(K<0&&(K+=12,j--),A)for(t=this._daylightSavingAdjust(new Date(A.getFullYear(),A.getMonth()-Y[0]*Y[1]+1,A.getDate())),t=T&&t<T?T:t;this._daylightSavingAdjust(new Date(j,K,1))>t;)--K<0&&(K=11,j--);for(e.drawMonth=K,e.drawYear=j,S=this._get(e,"prevText"),S=x?this.formatDate(S,this._daylightSavingAdjust(new Date(j,K-F,1)),this._getFormatConfig(e)):S,a=this._canAdjustMonth(e,-1,j,K)?V("<a>").attr({class:"ui-datepicker-prev ui-corner-all","data-handler":"prev","data-event":"click",title:S}).append(V("<span>").addClass("ui-icon ui-icon-circle-triangle-"+(C?"e":"w")).text(S))[0].outerHTML:I?"":V("<a>").attr({class:"ui-datepicker-prev ui-corner-all ui-state-disabled",title:S}).append(V("<span>").addClass("ui-icon ui-icon-circle-triangle-"+(C?"e":"w")).text(S))[0].outerHTML,S=this._get(e,"nextText"),S=x?this.formatDate(S,this._daylightSavingAdjust(new Date(j,K+F,1)),this._getFormatConfig(e)):S,i=this._canAdjustMonth(e,1,j,K)?V("<a>").attr({class:"ui-datepicker-next ui-corner-all","data-handler":"next","data-event":"click",title:S}).append(V("<span>").addClass("ui-icon ui-icon-circle-triangle-"+(C?"w":"e")).text(S))[0].outerHTML:I?"":V("<a>").attr({class:"ui-datepicker-next ui-corner-all ui-state-disabled",title:S}).append(V("<span>").attr("class","ui-icon ui-icon-circle-triangle-"+(C?"w":"e")).text(S))[0].outerHTML,F=this._get(e,"currentText"),I=this._get(e,"gotoCurrent")&&e.currentDay?N:B,F=x?this.formatDate(F,I,this._getFormatConfig(e)):F,S="",e.inline||(S=V("<button>").attr({type:"button",class:"ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all","data-handler":"hide","data-event":"click"}).text(this._get(e,"closeText"))[0].outerHTML),x="",w&&(x=V("<div class='ui-datepicker-buttonpane ui-widget-content'>").append(C?S:"").append(this._isInRange(e,I)?V("<button>").attr({type:"button",class:"ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all","data-handler":"today","data-event":"click"}).text(F):"").append(C?"":S)[0].outerHTML),s=parseInt(this._get(e,"firstDay"),10),s=isNaN(s)?0:s,r=this._get(e,"showWeek"),O=this._get(e,"dayNames"),L=this._get(e,"dayNamesMin"),R=this._get(e,"monthNames"),H=this._get(e,"monthNamesShort"),n=this._get(e,"beforeShowDay"),d=this._get(e,"showOtherMonths"),W=this._get(e,"selectOtherMonths"),c=this._getDefaultDate(e),o="",h=0;h<Y[0];h++){for(u="",this.maxRows=4,p=0;p<Y[1];p++){if(g=this._daylightSavingAdjust(new Date(j,K,e.selectedDay)),_=" ui-corner-all",f="",J){if(f+="<div class='ui-datepicker-group",1<Y[1])switch(p){case 0:f+=" ui-datepicker-group-first",_=" ui-corner-"+(C?"right":"left");break;case Y[1]-1:f+=" ui-datepicker-group-last",_=" ui-corner-"+(C?"left":"right");break;default:f+=" ui-datepicker-group-middle",_=""}f+="'>"}for(f+="<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix"+_+"'>"+(/all|left/.test(_)&&0===h?C?i:a:"")+(/all|right/.test(_)&&0===h?C?a:i:"")+this._generateMonthYearHeader(e,K,j,T,A,0<h||0<p,R,H)+"</div><table class='ui-datepicker-calendar'><thead><tr>",k=r?"<th class='ui-datepicker-week-col'>"+this._get(e,"weekHeader")+"</th>":"",l=0;l<7;l++)k+="<th scope='col'"+(5<=(l+s+6)%7?" class='ui-datepicker-week-end'":"")+"><span title='"+O[E=(l+s)%7]+"'>"+L[E]+"</span></th>";for(f+=k+"</tr></thead><tbody>",m=this._getDaysInMonth(j,K),j===e.selectedYear&&K===e.selectedMonth&&(e.selectedDay=Math.min(e.selectedDay,m)),D=(this._getFirstDayOfMonth(j,K)-s+7)%7,m=Math.ceil((D+m)/7),U=J&&this.maxRows>m?this.maxRows:m,this.maxRows=U,y=this._daylightSavingAdjust(new Date(j,K,1-D)),P=0;P<U;P++){for(f+="<tr>",z=r?"<td class='ui-datepicker-week-col'>"+this._get(e,"calculateWeek")(y)+"</td>":"",l=0;l<7;l++)v=n?n.apply(e.input?e.input[0]:null,[y]):[!0,""],b=(M=y.getMonth()!==K)&&!W||!v[0]||T&&y<T||A&&A<y,z+="<td class='"+(5<=(l+s+6)%7?" ui-datepicker-week-end":"")+(M?" ui-datepicker-other-month":"")+(y.getTime()===g.getTime()&&K===e.selectedMonth&&e._keyEvent||c.getTime()===y.getTime()&&c.getTime()===g.getTime()?" "+this._dayOverClass:"")+(b?" "+this._unselectableClass+" ui-state-disabled":"")+(M&&!d?"":" "+v[1]+(y.getTime()===N.getTime()?" "+this._currentClass:"")+(y.getTime()===B.getTime()?" ui-datepicker-today":""))+"'"+(M&&!d||!v[2]?"":" title='"+v[2].replace(/'/g,"&#39;")+"'")+(b?"":" data-handler='selectDay' data-event='click' data-month='"+y.getMonth()+"' data-year='"+y.getFullYear()+"'")+">"+(M&&!d?"&#xa0;":b?"<span class='ui-state-default'>"+y.getDate()+"</span>":"<a class='ui-state-default"+(y.getTime()===B.getTime()?" ui-state-highlight":"")+(y.getTime()===N.getTime()?" ui-state-active":"")+(M?" ui-priority-secondary":"")+"' href='#' aria-current='"+(y.getTime()===N.getTime()?"true":"false")+"' data-date='"+y.getDate()+"'>"+y.getDate()+"</a>")+"</td>",y.setDate(y.getDate()+1),y=this._daylightSavingAdjust(y);f+=z+"</tr>"}11<++K&&(K=0,j++),u+=f+="</tbody></table>"+(J?"</div>"+(0<Y[0]&&p===Y[1]-1?"<div class='ui-datepicker-row-break'></div>":""):"")}o+=u}return o+=x,e._keyEvent=!1,o},_generateMonthYearHeader:function(e,t,a,i,s,r,n,d){var c,o,l,h,u,p,g=this._get(e,"changeMonth"),_=this._get(e,"changeYear"),f=this._get(e,"showMonthAfterYear"),k=this._get(e,"selectMonthLabel"),D=this._get(e,"selectYearLabel"),m="<div class='ui-datepicker-title'>",y="";if(r||!g)y+="<span class='ui-datepicker-month'>"+n[t]+"</span>";else{for(c=i&&i.getFullYear()===a,o=s&&s.getFullYear()===a,y+="<select class='ui-datepicker-month' aria-label='"+k+"' data-handler='selectMonth' data-event='change'>",l=0;l<12;l++)(!c||l>=i.getMonth())&&(!o||l<=s.getMonth())&&(y+="<option value='"+l+"'"+(l===t?" selected='selected'":"")+">"+d[l]+"</option>");y+="</select>"}if(f||(m+=y+(!r&&g&&_?"":"&#xa0;")),!e.yearshtml)if(e.yearshtml="",r||!_)m+="<span class='ui-datepicker-year'>"+a+"</span>";else{for(n=this._get(e,"yearRange").split(":"),h=(new Date).getFullYear(),u=(k=function(e){e=e.match(/c[+\-].*/)?a+parseInt(e.substring(1),10):e.match(/[+\-].*/)?h+parseInt(e,10):parseInt(e,10);return isNaN(e)?h:e})(n[0]),p=Math.max(u,k(n[1]||"")),u=i?Math.max(u,i.getFullYear()):u,p=s?Math.min(p,s.getFullYear()):p,e.yearshtml+="<select class='ui-datepicker-year' aria-label='"+D+"' data-handler='selectYear' data-event='change'>";u<=p;u++)e.yearshtml+="<option value='"+u+"'"+(u===a?" selected='selected'":"")+">"+u+"</option>";e.yearshtml+="</select>",m+=e.yearshtml,e.yearshtml=null}return m+=this._get(e,"yearSuffix"),f&&(m+=(!r&&g&&_?"":"&#xa0;")+y),m+="</div>"},_adjustInstDate:function(e,t,a){var i=e.selectedYear+("Y"===a?t:0),s=e.selectedMonth+("M"===a?t:0),t=Math.min(e.selectedDay,this._getDaysInMonth(i,s))+("D"===a?t:0),i=this._restrictMinMax(e,this._daylightSavingAdjust(new Date(i,s,t)));e.selectedDay=i.getDate(),e.drawMonth=e.selectedMonth=i.getMonth(),e.drawYear=e.selectedYear=i.getFullYear(),"M"!==a&&"Y"!==a||this._notifyChange(e)},_restrictMinMax:function(e,t){var a=this._getMinMaxDate(e,"min"),e=this._getMinMaxDate(e,"max"),a=a&&t<a?a:t;return e&&e<a?e:a},_notifyChange:function(e){var t=this._get(e,"onChangeMonthYear");t&&t.apply(e.input?e.input[0]:null,[e.selectedYear,e.selectedMonth+1,e])},_getNumberOfMonths:function(e){e=this._get(e,"numberOfMonths");return null==e?[1,1]:"number"==typeof e?[1,e]:e},_getMinMaxDate:function(e,t){return this._determineDate(e,this._get(e,t+"Date"),null)},_getDaysInMonth:function(e,t){return 32-this._daylightSavingAdjust(new Date(e,t,32)).getDate()},_getFirstDayOfMonth:function(e,t){return new Date(e,t,1).getDay()},_canAdjustMonth:function(e,t,a,i){var s=this._getNumberOfMonths(e),a=this._daylightSavingAdjust(new Date(a,i+(t<0?t:s[0]*s[1]),1));return t<0&&a.setDate(this._getDaysInMonth(a.getFullYear(),a.getMonth())),this._isInRange(e,a)},_isInRange:function(e,t){var a,i=this._getMinMaxDate(e,"min"),s=this._getMinMaxDate(e,"max"),r=null,n=null,e=this._get(e,"yearRange");return e&&(e=e.split(":"),a=(new Date).getFullYear(),r=parseInt(e[0],10),n=parseInt(e[1],10),e[0].match(/[+\-].*/)&&(r+=a),e[1].match(/[+\-].*/))&&(n+=a),(!i||t.getTime()>=i.getTime())&&(!s||t.getTime()<=s.getTime())&&(!r||t.getFullYear()>=r)&&(!n||t.getFullYear()<=n)},_getFormatConfig:function(e){var t=this._get(e,"shortYearCutoff");return{shortYearCutoff:"string"!=typeof t?t:(new Date).getFullYear()%100+parseInt(t,10),dayNamesShort:this._get(e,"dayNamesShort"),dayNames:this._get(e,"dayNames"),monthNamesShort:this._get(e,"monthNamesShort"),monthNames:this._get(e,"monthNames")}},_formatDate:function(e,t,a,i){t||(e.currentDay=e.selectedDay,e.currentMonth=e.selectedMonth,e.currentYear=e.selectedYear);i=t?"object"==typeof t?t:this._daylightSavingAdjust(new Date(i,a,t)):this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return this.formatDate(this._get(e,"dateFormat"),i,this._getFormatConfig(e))}}),V.fn.datepicker=function(e){if(!this.length)return this;V.datepicker.initialized||(V(document).on("mousedown",V.datepicker._checkExternalClick),V.datepicker.initialized=!0),0===V("#"+V.datepicker._mainDivId).length&&V("body").append(V.datepicker.dpDiv);
vendor: 543 bytes, line 3024
3024var t=Array.prototype.slice.call(arguments,1);return"string"==typeof e&&("isDisabled"===e||"getDate"===e||"widget"===e)||"option"===e&&2===arguments.length&&"string"==typeof arguments[1]?V.datepicker["_"+e+"Datepicker"].apply(V.datepicker,[this[0]].concat(t)):this.each(function(){"string"==typeof e?V.datepicker["_"+e+"Datepicker"].apply(V.datepicker,[this].concat(t)):V.datepicker._attachDatepicker(this,e)})},V.datepicker=new e,V.datepicker.initialized=!1,V.datepicker.uuid=(new Date).getTime(),V.datepicker.version="1.13.3",V.datepicker});

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.