PageSourceSearch

https://yachtrock.radio/wp-content/themes/proradio/js/qtt-main.js?ver=9.5

js yachtrock.radio collected 2026-10-07 01:54:53 UTC 74,201 bytes, 2,450 lines download raw bytes

1/**====================================================================
2 *
3 *  Main Script File
4 *  V. 2.0
5 *
6 *====================================================================*/
7
8 /*====================================================================
9
10	CODEKIT PREPENDS:
11	THESE BELOW ARE NOT COMMENTS, BUT THE CODEKIT'S PREPEND FILES 
12	ENQUEUED IN MAIN-MIN.JS
13
14	TO USE THE OPEN VERSION OF THE FILES FOR YOUR CUSTOMIZATIONS, 
15	ENABLE THE DEBUG OPTIONS IN THE THEME'S CUSTOMIZER
16
17====================================================================*/
18
19// @codekit-prepend "../components/ajax-page-load/_proradio-ajax-pageload.js";
20// @codekit-prepend "../components/materialize-src/js/collapsible.js";
21// @codekit-prepend "../components/materialize-src/js/jquery.easing.1.3.js";
22// @codekit-prepend "../components/modernizr/modernizr-custom.js";
23// @codekit-prepend "../components/owl-carousel/dist/owl.carousel-min.js";
24// @codekit-prepend "../components/stellar/jquery.stellar.js";
25// @codekit-prepend "../components/ttg-stickysidebar/min/ttg-sticky-sidebar-min.js";
26// @codekit-prepend "../js/skip-link-focus-fix.js";
27
28
29
30 
31(function($) {
32	"use strict";
33	$.fn.waterwave = function( options ) {
34		// DEFAULT OPTIONS
35		var settings = $.extend({
36			parent : '',
37			color : '#fff',
38			direction: 'down',
39			background: '',
40			speed: 1
41		}, options );
42		var waterwave = this;
43		waterwave.init = function() {
44			var TAU = Math.PI * 2.5;
45			var density = 1;
46			var speed = options.speed;
47			var res = 0.005; // percentage of screen per x segment
48			var outerScale = 0.05 / density;
49			var inc = 0;
50			var c = waterwave[0];
51			var ctx = c.getContext('2d');
52			var grad = ctx.createLinearGradient(0, 0, 0, c.height * 4);
53			var height = options.parent.outerHeight();
54			var width = options.parent.outerWidth();
55
56			function onResize() {
57				if(options.direction == 'down') {
58					waterwave.attr({
59						width: width+ "px"
60					});
61				}
62				else {
63					waterwave.attr({
64						width:  width+ "px",
65						height: height + "px"
66					});
67				}
68			}
69
70			onResize();
71			setTimeout(function() {
72				loop();
73			}, 500);
74			$(window).resize(onResize);
75
76			function loop() {
77				inc -= speed;
78				drawWave(options.color);
79				requestAnimationFrame(loop);
80			}
81
82
83			function drawBG(patternCanvas, w, h) {
84				var space = ctx.createPattern(patternCanvas, 'repeat');
85				ctx.fillStyle = space;
86				ctx.fillRect(0, 0, w, h);
87			}
88
89			function drawWave(color) {
90				var w = c.offsetWidth;
91				var h = c.offsetHeight;
92				var cx = w * 0.5;
93				var cy = h * 0.5;
94				ctx.clearRect(0, 0, w, h);
95				var segmentWidth = w * res;
96				if(options.background != '') {
97					var image = new Image();
98					image.src = options.background;
99					image.onload = function() {
100						// create an off-screen canvas
101						var patt = document.createElement('canvas');
102						// set the resized width and height
103						patt.width = w;
104						patt.height = h;
105						patt.getContext('2d').drawImage(this, 0, - 1 * (h / 4), patt.width, patt.height);
106						// pass the resized canvas to your createPattern
107						drawBG(patt, w , h);
108					};
109				}
110				else {
111					ctx.fillStyle = color;
112				}
113				ctx.beginPath();
114				ctx.moveTo(0, cy);
115				for (var i = 0, endi = 1 / res; i <= endi; i++) {
116					var _y = cy + Math.sin((i + inc) * TAU * res * density) * cy * Math.sin(i * TAU * res * density * outerScale);
117					var _x = i * segmentWidth;
118					ctx.lineTo(_x, _y);
119				}
120				if(options.direction == 'down') {
121					ctx.lineTo(w, 0);
122					ctx.lineTo(0, 0);
123				}
124				else {
125					ctx.lineTo(w, h);
126					ctx.lineTo(0, h);
127				}
128				ctx.closePath();
129				ctx.fill();
130			}
131		};
132		waterwave.init();
133		return waterwave;
134	};
135
136
137	/**
138	 * Website functionalities
139	 */
140
141	$.ProRadioMainObj = {
142		/**
143		 * Global function variables and main objects
144		 */
145		body: $("body"),
146		window: $(window),
147		document: $(document),
148		htmlAndbody: $('html,body'),
149		scrolledTop: 0, // global value of the amount of top scrolling
150		oldScroll: 0,
151		scroDirect: false,
152		clock: false,
153		headerbar: $('#proradio-headerbar'),
154		stickyheader: $('[data-proradio-stickyheader]'),
155		clockTimer: 50,
156		clockTimerMobile: 180,
157
158		/**
159		 * ======================================================================================================================================== |
160		 * 																																			|
161		 * 																																			|
162		 * START SITE FUNCTIONS 																													|
163		 * 																																			|
164		 *																																			|
165		 * ======================================================================================================================================== |
166		 */
167		
168		fn: {
169			window: $(window),
170			isExplorer: function(){
171				return /Trident/i.test(navigator.userAgent) ;
172			},
173			isSafari: function(){
174				return navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1;
175			},
176			isMobile: function(){
177				return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || $.ProRadioMainObj.window.width() < 1170 ;
178			},
179			isLowPerformance: function(){
180				return (  navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1 ) || /Trident/i.test(navigator.userAgent) ;
181			},
182			doDebug: function(msg){
183				if( $("body").hasClass('proradio-jsdebug') ){
184					console.log(msg);
185				}
186			},
187			areClipPathShapesSupported: function(){
188				var base = 'clipPath',
189					prefixes = [ 'webkit', 'moz', 'ms', 'o' ],
190					properties = [ base ],
191					testElement = document.createElement( 'testelement' ),
192					attribute = 'polygon(50% 0%, 0% 100%, 100% 100%)';
193
194				// Push the prefixed properties into the array of properties.
195				for ( var i = 0, l = prefixes.length; i < l; i++ ) {
196					var prefixedProperty = prefixes[i] + base.charAt( 0 ).toUpperCase() + base.slice( 1 ); // remember to capitalize!
197					properties.push( prefixedProperty );
198				}
199
200				// Interate over the properties and see if they pass two tests.
201				for ( var i = 0, l = properties.length; i < l; i++ ) {
202					var property = properties[i];
203
204					// First, they need to even support clip-path (IE <= 11 does not)...
205					if ( testElement.style[property] === '' ) {
206
207						// Second, we need to see what happens when we try to create a CSS shape...
208						testElement.style[property] = attribute;
209						if ( testElement.style[property] !== '' ) {
210							 $("body").addClass('proradio-clip-enabled');
211							 return true;
212						}
213					}
214				}
215				$("body").addClass('proradio-clip-disabled');
216				return false;
217			},
218
219			
220
221			/** random id when required
222			====================================================================*/
223			uniqId: function() {
224			  return Math.round(new Date().getTime() + (Math.random() * 100));
225			},
226
227			
228
229
230
231
232
233
234
235
236
237
238			
239		
240
241			/**====================================================================
242			 *
243			 *
244			 * Tree Menu
245			 *
246			 * 
247			 ====================================================================*/
248			treeMenu: function() {
249				$( ".proradio-menu-tree li.menu-item-has-children" ).each(function(i,c){
250					var t = $(c);
251					t.find('> a').after("<a class='proradio-openthis' href='#'><i class='material-icons'>keyboard_arrow_down</i></a>");
252					var sub = t.children('ul');
253					t.on("click","> .proradio-openthis", function(e){
254						e.preventDefault();
255						t.toggleClass("proradio-open");
256					});
257				});
258			},
259
260
261			/**====================================================================
262			 *
263			 *
264			 * Automatic link embed
265			 *
266			 * 
267			 ====================================================================*/
268			embedVideo: function (content, width, height) {
269				height = width / 16 * 9;
270				var youtubeUrl = content;
271				var youtubeId = youtubeUrl.match(/=[\w-]{11}/);
272				var strId = youtubeId[0].replace(/=/, '');
273				var result = '<iframe width="'+width+'" height="'+height+'" src="'+window.location.protocol+'//www.youtube.com/embed/' + strId + '?html5=1" class="youtube-player" allowfullscreen></iframe>';
274				return result;
275			},
276
277			embedSpotify: function(mystring, width, height){
278				var isPodcast =  /episode/i.test(mystring);
279				if(isPodcast){
280					var trackID = mystring.split('https://open.spotify.com/episode/').join('');
281					var url = 'https://open.spotify.com/embed/episode/'+trackID;
282					height= 160;
283				} else {
284					var url = mystring.split('?')[0];
285					var trackAr = url.split('/track/');
286					var url = 'https://open.spotify.com/embed/track/'+trackAr[1];
287				}
288				if( url ){
289					return '<iframe src="'+url+'" width="'+width+'" height="'+height+'" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>';
290				}
291			},
292
293			transformlinks: function (targetContainer, differ) {
294				if(undefined === targetContainer) {
295					targetContainer = "body";
296				}
297				if(undefined === differ) {
298					differ = false;
299				}
300				var obj = $.ProRadioMainObj;
301				var embeddedPlayer;
302				jQuery(targetContainer).find("a[href*='youtube.com'],a[href*='youtu.be'],a[href*='mixcloud.com'],a[href*='soundcloud.com'], [data-autoembed]").not('.noembed').not('.qw-disableembedding').not('.qt-disableembedding').not('.data-elementor-open-lightbox').each(function(element) {
303					var that = jQuery(this),
304						mystring = that.attr('href'),
305						width = that.parent().width(),
306						height = that.height(),
307						box = that,
308						fixedheight = that.data('fixedheight');
309					if(differ === false && that.hasClass('qt-differembed')){
310						return;
311					}
312					if(width === 0){
313						width = that.parent().parent().parent().width();
314					}
315					if(width === 0){
316						width = that.parent().parent().parent().width();
317					}
318					if(width === 0){
319						width = that.parent().parent().parent().parent().width();
320					}
321					if(that.attr('data-autoembed')) {
322						mystring = that.attr('data-autoembed');
323					}
324					//=== YOUTUBE 
325					var expression = /(http|https):\/\/(\w{0,3}\.)?youtube\.\w{2,3}\/watch\?v=[\w-]{11}/gi,
326						videoUrl = mystring.match(expression);
327					if (videoUrl !== null) {
328						for (var count = 0; count < videoUrl.length; count++) {
329							mystring = mystring.replace(videoUrl[count], $.ProRadioMainObj.fn.embedVideo(videoUrl[count], width, (width/16*9)));
330							replacethisHtml(mystring);
331						}
332					}    
333					//=== SPOTIFY 
334					var expression = /https:\/\/open\.spotify\.\w{2,3}\/track\/[\w-]{22}/gi;
335					var	trackurl = mystring.match(expression);
336
337					if (trackurl == null) {
338						expression = /https:\/\/open\.spotify\.\w{2,3}\/intl-[A-Za-z0-9]+\/track\/[\w-]{22}/gi;
339						trackurl = mystring.match(expression);
340					}
341					if (trackurl == null) {
342						expression = /https:\/\/open\.spotify\.\w{2,3}\/episode\/[\w-]{22}/gi,
343						trackurl = mystring.match(expression);
344					}
345				
346
347
348
349					if (trackurl !== null) {
350						for (var count = 0; count < trackurl.length; count++) {
351							replacethisHtml($.ProRadioMainObj.fn.embedSpotify( trackurl[count], width, 80 ));
352						}
353					} 
354
355					//=== SOUNDCLOUD
356					var temphtml = '',
357						iframeUrl = '',
358						$temphtml,
359						expression = /(http|https)(\:\/\/soundcloud.com\/+([a-zA-Z0-9\/\-_]*))/g,
360						scUrl = mystring.match(expression);
361					if (scUrl !== null) {
362						for (count = 0; count < scUrl.length; count++) {
363							var finalurl = scUrl[count].replace(':', '%3A');
364							if(!fixedheight){
365								fixedheight = 180;
366							}
367							jQuery.getJSON(
368								'https://soundcloud.com/oembed?maxheight='+fixedheight+'&format=js&url=' + finalurl + '&iframe=true&callback=?', 
369								function(response) {
370									temphtml = response.html;
371									replacethisHtml(temphtml);
372									// if(that.closest("li").length > 0){
373									// 	if(that.closest("li").hasClass("qt-collapsible-itemX") ) {
374									// 		$temphtml = $(temphtml);
375									// 		iframeUrl = $temphtml.attr("src");
376									// 		replacethisHtml('<div class="qt-dynamic-iframe" data-src="'+iframeUrl+'"></div>');
377									// 	} else {
378									// 		replacethisHtml(temphtml);
379									// 	}
380									// } else {
381									// 	replacethisHtml(temphtml);
382									// }
383							});
384						}
385					}
386					//=== MIXCLOUD
387					var expression = /(http|https)\:\/\/www\.mixcloud\.com\/[\w-]{0,150}\/[\w-]{0,150}\/[\w-]{0,1}/ig;
388					var mixcloudUrl = mystring.match(expression);
389					if (mixcloudUrl !== null) {
390						for (count = 0; count < mixcloudUrl.length; count++) {
391							var finalurl = encodeURIComponent(mixcloudUrl[count]);
392							var embedcode ='<iframe data-state="0" class="mixcloudplayer" width="100%" height="160" src="//www.mixcloud.com/widget/iframe/?feed='+finalurl+'&embed_uuid=addfd1ba-1531-4f6e-9977-6ca2bd308dcc&stylecolor=&embed_type=widget_standard"></iframe><div class="canc"></div>';    
393							replacethisHtml(embedcode);
394						}
395					}
396					//=== STRING REPLACE (FINAL FUNCTION)
397					function replacethisHtml(mystring) {
398						if(box.is("a")){
399							box.replaceWith(mystring);
400						} else {
401							box.html(mystring);
402						}
403						return true;
404					}
405					obj.fn.YTreszr();
406				});
407				
408				/**
409				 * Fix for soundcloud loaded in collapsed div for the chart
410				 */
411				obj.body.off('click','.qt-collapsible li');
412				obj.body.on('click','.qt-collapsible li', function(e){
413					var that = $(this);
414					if(that.hasClass("active")){
415						obj.fn.transformlinks('#'+that.attr("id"), true);
416						// Not needed anymore, replaced with new differ system on 2022 06 14
417						// var item = that.find(".qt-dynamic-iframe");
418						// var itemurl = item.attr("data-src");
419						// item.replaceWith('<iframe src="'+itemurl+'" frameborder="0"></iframe>');
420						obj.fn.YTreszr();
421						
422						
423					}
424				});
425				// @since 7.3 
426				// Play inner song if there is a player
427				obj.body.on('click','.qt-collapsible li .proradio-position i', function(e){
428					var li = $(this).closest('li');
429					li.animate({},30).delay(50).promise().done(function(){
430						var playb = $(this).closest('li').find('.qtmplayer-trackitem');
431						if(li.hasClass('active') && ! playb.hasClass('qtmplayer-played')){
432							playb.find('[data-qtmplayer-file]').click();
433						}
434					});
435					
436					// if(! that.hasClass("active")){
437					// 	var playable = that.find('.qtmplayer-trackitem [data-qtmplayer-file]');
438					// 	if(playable.length > 0){
439					// 		playable.click();
440					// 	}
441					// }
442				});
443
444				obj.body.off('click','ul.tabs li a');
445				obj.body.on('click','ul.tabs li a', function(e){
446					obj.fn.YTreszr();
447					window.dispatchEvent(new Event('resize'));
448				});
449			},
450			
451			/* activates
452			*  Adds and removes the class "proradio-active" from the target item	
453			====================================================================*/
454			activatesComponent: function(targetContainer){
455				if(undefined === targetContainer) {
456					targetContainer = "body";
457				}
458				var t, // target
459					o = $.ProRadioMainObj,
460					s = false;
461
462				$(targetContainer).find('[data-proradio-activates]').each(function(i,c){
463					var btn = $(c), s;
464					btn.off("click");
465					btn.on("click", function(e){
466						e.preventDefault();
467						$(this).toggleClass("proradio-enabled")
468						s = $(this).attr("data-proradio-activates");
469						t = $(s);
470						if(!s || s === ''){
471							t = $(this); }
472						if( s == 'parent'){
473							t = $(this).parent(); }
474						if( s == 'gparent'){
475							t = $(this).parent().parent(); }
476						t.toggleClass("proradio-enabled"); // changed on 2020 04 06 because the class proradio-actived was used by the laodmore
477						return;
478					});
479				});
480			},
481
482			tabsComponent: function( targetContainer ){
483				
484				if(undefined === targetContainer) {
485					targetContainer = "body";
486				}
487				var t, // target
488					o = $.ProRadioMainObj,
489					s = false;
490
491				$(targetContainer).find('[data-proradio-tabs]').each(function(i,c){
492					var btn = $(c).find('.proradio-tabs__menu a'), 
493						s,
494						tcnt = $(c).find('.proradio-tabs__content');
495
496					// tcnt.fadeOut('fast').first().fadeIn('fast'); // Breaking in certain conditions, so disabled
497					
498					// 2019 12 19 preactivate a tab
499					var activeTab = $(c).find('.proradio-active');
500					if( 0 == activeTab.length ){
501						tcnt.first().show();
502						$(c).find('.proradio-tabs__menu li:first-child a').addClass('proradio-active');
503					} else {
504						tcnt.hide();
505						$( activeTab.attr("href") ).show();
506					}
507
508					btn.off("click");
509					btn.on("click", function(e){
510						e.preventDefault();
511						var t = $(this);
512						$(c).find('.proradio-tabs__menu a.proradio-active').removeClass('proradio-active');
513						t.addClass("proradio-active");
514						s = t.attr("href");
515						tcnt.fadeOut('fast').promise().done(function(){
516							$(s).fadeIn('fast');
517						});
518						return;
519					});
520				});
521			},
522
523			/* switchClass
524			*  toggles the class defined with "data-proradio-switch" from the target element data-proradio-target
525			*  used to change state of other items (search and similar)
526			====================================================================*/
527			switchClass: function( targetContainer ){
528				
529				if(undefined === targetContainer) {
530					targetContainer = "body";
531				}
532				$(targetContainer).off("click",  "[data-proradio-switch]").on("click",  "[data-proradio-switch]", function(e){
533					e.preventDefault();
534					var tc = $(this).attr("data-proradio-target"); // selector
535					var t = $(tc); // target
536					var c = $(this).attr("data-proradio-switch"); // class
537					t.toggleClass(c);
538					if(tc === '#proradio-searchbar'){
539						if(t.hasClass(c)){
540							setTimeout(function() { $('#proradio-searchbar input').focus() }, 200);
541						} else {
542							$('#proradio-searchbar input').blur();
543						}
544					}
545				});
546			},
547
548			extractYoutubeId: function(url){
549				if(void 0===url)return!1;
550				var id=url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
551				return null!==id&&id[1];
552			},
553
554			/**
555			 * Fix video background Page Builder rows su ajax load
556			 */
557			qtVcVideobg: function(){
558				var o = $.ProRadioMainObj,
559					f = o.fn,
560					ytu, t, vid;
561				if( !f.isMobile() && typeof( insertYoutubeVideoAsBackground ) == 'function' && typeof(vcResizeVideoBackground) == 'function' ){
562					jQuery("[data-proradio-video-bg]").each(
563						function(){
564							t = $(this);
565							var videoId = f.extractYoutubeId(t.data("proradio-video-bg"));
566							insertYoutubeVideoAsBackground( t, videoId );
567							vcResizeVideoBackground(t);
568						}
569					);
570				}
571			},
572
573			
574			/**====================================================================
575			 *
576			 *
577			 *	 Responsive video resize
578			 *
579			 * 
580			 ====================================================================*/
581			YTreszr: function  (){
582				jQuery("iframe").each(function(i,c){ // .youtube-player
583					var t = jQuery(this);
584					if(t.attr("src")){
585						var href = t.attr("src");
586						if(href.match("youtube.com") || href.match("vimeo.com") || href.match("vevo.com")  ){
587							var width = t.parent().width(),
588								height = t.height();
589							t.css({"width":width});
590							t.height(width/16*9);
591						}
592						else if(href.match("soundcloud.com")){
593							var width = t.parent().width();
594							t.css({"width":width});
595						}; 
596					};
597				});
598			},
599
600			/* Fix background in safari
601			====================================================================*/
602
603			ipadBgFix: function(){
604				var o = $.ProRadioMainObj,
605					f = o.fn;
606				if(f.isMobile() && f.isSafari()){
607					o.body.addClass('proradio-safari-mobile');
608				}
609			},
610
611			/* Parallax background
612			====================================================================*/
613			qtParallax: function(){
614				
615				if('function' !== typeof($.fn.stellar) ){
616					return;
617				}
618				if(  $('[data-proradio-parallax]').length == 0 ){
619					return;
620				}
621				var o = $.ProRadioMainObj,
622					b = o.body;
623				if(o.fn.isMobile()){return;}
624				if('function' === typeof($.fn.stellar) ){
625					b.stellar('destroy');
626					$.stellar.positionProperty.apple = {
627						setTop: function($el, newTop, originalTop) {
628							$el.css({
629								'top': originalTop - newTop,
630								'left': $el.hasClass('apple') ? originalTop - newTop : 0
631							});
632						}
633					};
634					$.each($('[data-proradio-parallax]'), function(i,c){
635						$(c).css({'transform':'translate3d'});
636						$(c).imagesLoaded().then(function(){
637							b.stellar({
638								hideDistantElements: false,
639								horizontalScrolling: false,
640							});
641						});
642					});
643				}
644			},
645
646			/* scrolledTop: set a global parameter with the amount of top scrolling
647			*	Used by themeScroll
648			====================================================================*/
649			scrolledTop: function(){
650				var o = $.ProRadioMainObj,
651					s = window.pageYOffset || document.documentElement.scrollTop,
652					d = 0;
653				d = o.scrolledTop - s;
654				if(d != 0){
655					o.scroDirect = d;
656				}
657				o.scrolledTop = s;
658				return s;
659			},
660
661			/* Sticky sidebar preparation
662			====================================================================*/
663			stickyBarLinkPrep: function  (){
664				
665				var o 		= $.ProRadioMainObj,
666					ab = $('#wpadminbar'),
667					ah = ab.outerHeight(),
668					fm = $('#proradio-menu'),
669					fh = fm.outerHeight(),
670					cando = o.fn.areClipPathShapesSupported();
671				if(false === cando)return;
672				o.OTS = $("#proradio-sticky"); // Object To Stick (BAR container)
673				if(o.OTS.length === 0)return;
674				o.OTSc = $('#proradio-stickycon'); // Object To Stick CONTENT (internal menu)
675				var OTS 	= o.OTS,
676					OTSh 	=	OTS.outerHeight();
677				OTS.css({'height': Math.round( OTSh )+'px'});
678				OTS.closest('.proradio-vc-row-container').addClass('proradio-stickybar-parent'); // 7 may
679				o.StickMeTo = 0;
680				o.whenToStick = $('.proradio-stickybar-parent').position().top - OTSh;
681				if( o.stickyheader.length > 0 ){
682					o.whenToStick -= fh;
683					o.StickMeTo += fh;
684				}
685				if(ab.length >= 1){
686					o.whenToStick -= ah;
687					o.StickMeTo += ah;
688				}
689				o.whenToStick = Math.floor(o.whenToStick);
690				o.StickMeTo = Math.floor(o.StickMeTo);
691
692			},
693			/* Sticky header
694			====================================================================*/
695			stickyBarLink: function  (st){
696				var o = $.ProRadioMainObj,
697					smt = o.StickMeTo,
698					wts = o.whenToStick,
699					cando = o.fn.areClipPathShapesSupported();
700				if(o.OTS.length === 0 || false === cando)return;
701				if(st >= wts ){
702					o.OTS.addClass("proradio-stickme");
703					o.OTSc.addClass('proradio-paper').css({ 'top': smt+'px'} );
704				} else {
705					o.OTSc.removeClass('proradio-paper');
706					o.OTS.removeClass("proradio-stickme");
707				}
708			},
709
710			/* Sticky menu
711			====================================================================*/
712			stickyMenuOld: {
713
714				doScrolledAction: $('body').hasClass('proradio-menu-stick'),
715				init: function(){
716					var that = $(this);
717					$.ProRadioMainObj.body.addClass('proradio-unscrolled');
718				},
719				pageScrolled: function (st, direction){
720					var that = $(this)[0];
721					if( true === that.doScrolledAction ){
722						var o = $.ProRadioMainObj,
723							c = "proradio-headerbar__sticky__s";
724						if( direction === 'up'){
725							o.headerbar.removeClass(c);
726						} else {
727							if( st > 30 ){
728								o.headerbar.addClass(c);
729							}
730						}
731						if( st > 30 ){
732							o.body.removeClass('proradio-unscrolled');
733							o.body.addClass('proradio-scrolled');
734						} else {
735							o.body.addClass('proradio-unscrolled');
736							o.body.removeClass('proradio-scrolled');
737						}
738					}
739					
740				}
741			},
742
743			stickyMenu: {
744
745				doScrolledAction: $('body').hasClass('proradio-menu-stick'),
746				scrollDirection: false,
747				scrollDistance: 0,
748
749				init: function(){
750					$.ProRadioMainObj.body.addClass('proradio-unscrolled');
751				},
752
753				trackScroll: function(st, os){
754					var that = this,
755						direction = st > os ? 'down' : 'up',
756						delta = Math.abs(st - os);
757
758					// Lo stato vicino alla cima deve essere sempre autorevole.
759					if(st <= 30){
760						that.scrollDirection = 'up';
761						that.scrollDistance = 0;
762						that.pageScrolled(st, 'up');
763						return;
764					}
765
766					// Quando cambia direzione, ricomincia il conteggio.
767					if(direction !== that.scrollDirection){
768						that.scrollDirection = direction;
769						that.scrollDistance = 0;
770					}
771
772					that.scrollDistance += delta;
773
774					if(that.scrollDistance < 30){
775						return;
776					}
777
778					that.scrollDistance = 0;
779
780					if(direction === 'down'){
781						that.pageScrolled(st, 'down');
782					} else if(st < 400){
783						that.pageScrolled(st, 'up');
784					}
785				},
786
787				pageScrolled: function(st, direction){
788					var that = $(this)[0];
789
790					if(true === that.doScrolledAction){
791						var o = $.ProRadioMainObj,
792							c = "proradio-headerbar__sticky__s";
793
794						if(direction === 'up'){
795							o.headerbar.removeClass(c);
796						} else if(st > 30){
797							o.headerbar.addClass(c);
798						}
799
800						if(st > 30){
801							o.body
802								.removeClass('proradio-unscrolled')
803								.addClass('proradio-scrolled');
804						} else {
805							o.body
806								.addClass('proradio-unscrolled')
807								.removeClass('proradio-scrolled');
808						}
809					}
810				}
811			},
812			
813			/* Item menu right align: add class if item is > half
814			====================================================================*/
815			menuItemAlign: function(){
816				
817				var o = $.ProRadioMainObj,
818					b = o.body,
819					items = b.find('.proradio-menubar > li.menu-item'),
820					hw = b.width() / 2;
821				if(items.length == 0){ return; }
822				items.each(function(i,c){
823					
824					var t = $(c);
825					if(t.offset().left > hw){
826						t.addClass('proradio-iright');
827					}
828				});
829			},
830
831			
832
833			/* Countdown
834			====================================================================*/
835			countDown: {
836
837				cd: $(".proradio-countdown"),
838				cdf: this,
839				pad: function(n,size) {
840					return (n < size) ? ("0" + n) : n;
841				},
842				doClock:function(T, item){
843					var cd = item;
844					if(!cd.data('proradio-date') || !cd.data('proradio-time')){
845						T.remove(cd);
846						return;
847					}
848					var days, hours, min,
849						cdf = T.cdf,
850						html = '',
851						fieldNow = cd.data('proradio-now'),
852						nowdate = new Date(fieldNow),
853						curDate = new Date(),
854						fieldDate = cd.data('proradio-date').split('-'),
855						fieldTime = cd.data('proradio-time').split(':'),
856
857						label_days = cd.data('proradio-days'),
858						label_hours = cd.data('proradio-hours'),
859						label_minutes = cd.data('proradio-minutes'),
860						label_seconds = cd.data('proradio-seconds'),
861						label_msec = cd.data('proradio-msec'),
862
863						futureDate = new Date(fieldDate[0],fieldDate[1]-1,fieldDate[2], fieldTime[0], fieldTime[1]),
864						sec = futureDate.getTime() / 1000 - curDate.getTime() / 1000,
865						msec =  futureDate.getTime() -  curDate.getTime();
866					
867					if(sec<=0 || isNaN(sec)){
868						T.remove(cd);
869						return cd;
870					}
871
872					days = Math.floor(sec/86400);
873					sec = sec%86400;
874					hours = Math.floor(sec/3600);
875					sec = sec%3600;
876					min = Math.floor(sec/60);
877					sec = Math.floor(sec%60);
878					msec = Math.floor(msec%1000);
879
880					cd.find('.d .n').text(T.pad(days,10));
881					cd.find('.h .n').text(T.pad(hours,10));
882					cd.find('.m .n').text(T.pad(min,10));
883					cd.find('.s .n').text(T.pad(sec,10));
884					cd.find('.ms .n').text(T.pad(msec,100));
885				},
886				showclock: function() {
887					
888					
889				},
890				remove: function(cd){
891					var T = $.ProRadioMainObj.fn.countDown;
892					cd.closest('.proradio-countdown__container').remove();
893					if(T.qtClockInterval){
894						clearInterval(T.qtClockInterval);
895					}
896				},
897				init: function() {
898					var T = $.ProRadioMainObj.fn.countDown,
899						cd = $(".proradio-countdown");
900					if(cd.length < 1){
901						return;
902					}
903					cd.each(function(i,c){
904						T.doClock( T, $(c) );
905					});
906					if(T.qtClockInterval){
907						clearInterval(T.qtClockInterval);
908					}
909					T.qtClockInterval = setInterval(function(){
910						cd.each(function(i,c){
911							T.doClock( T, $(c) );
912						});
913					},107); // arbitrary delay for refresh to avoid js overload. 
914				}
915			},
916
917
918			/* custom waypoints component
919			====================================================================*/
920			qtWaypoints: {
921				items: [],
922				isloaded: false,
923				reinitialize: function(){
924					this.items = [];
925					this.prepare();
926				},
927				init: function(){
928					var f = this;
929					$.ProRadioMainObj.window.on( "load", function(){
930						setTimeout(
931							function(){
932								f.prepare();
933							}, 
934						200);
935					});
936				},
937				prepare: function(){
938					var f = this; 
939					f.wh = $(window).height();
940					var itemid = 0;
941					$('[data-qtwaypoints]').each(function(i,c){
942						var item = [];
943						item['id'] = itemid;
944						item['el'] = $(c);
945						item['offset'] = $(c).attr('data-qtwaypoints-offset') || 50; // default 50px offset
946						item['addclass'] = $(c).attr('data-qtwaypoints-addclass') || 'proradio-active';
947						item['rewind'] = $(c).attr('data-qtwaypoints-rewind') || false;
948						item['itemtop'] =  Math.floor( parseInt( $(c).offset().top ) + parseInt( item['offset'] ) );
949						if( item['itemtop'] < f.wh ){
950							item['el'].addClass( item['addclass'] );
951						} 
952						f.items.push(item);
953						itemid++;
954					});
955					this.isloaded = true;
956					this.update(0);
957				},
958				update: function(st){
959					if( false === this.isloaded ){
960						return;
961					}
962					var timeout = false;
963					var f = this;
964					var item;
965					var virwportBottom;
966					var itemtop;
967					var el, offset, addclass, rewind;
968					if(timeout){
969						clearTimeout(timeout);
970					}
971					timeout = setTimeout(function(o){
972						virwportBottom = st + f.wh;
973						$.each( f.items , function(i,c){
974							el = c['el'];
975							c['animating'] = 1;
976							offset = c['offset'];
977							rewind = c['rewind'];
978							addclass = c['addclass'];
979							itemtop = c['itemtop'];
980							if( itemtop < virwportBottom ){
981								if(!el.hasClass(addclass)){
982									el.addClass(addclass);
983								}
984							} else {
985								if(rewind){
986									el.removeClass(addclass);
987								}
988							}
989							f.items[i]['animating'] = 1;
990						});
991
992
993						
994
995					}, 30);
996
997
998
999
1000				}
1001			},
1002			//159
1003
1004
1005
1006			/* Scrollspy
1007			====================================================================*/
1008			qtScrollSpy: {
1009				init: function(){
1010					function qtScrollSpyInit(){
1011						var o = $.ProRadioMainObj,
1012							cando = o.fn.areClipPathShapesSupported(),
1013							b = o.body,
1014							intmenu = $('#proradio-sticky'),
1015							offset = 0,
1016							sh = o.stickyheader,
1017							adminbar = $("#wpadminbar"),
1018							sections = [],
1019							pagemiddle =  Math.floor( $(window).height() / 2 );
1020						o.scrollspycontainer = b.find("[data-proradio-scrollspy]");
1021						if(intmenu.length > 0 ){
1022							offset = offset + 70;
1023						}
1024						if(sh.length > 0 ){
1025							offset = offset + sh.find('#proradio-menu').outerHeight();
1026						}
1027						if(adminbar.length > 0 ){
1028							offset = offset + adminbar.outerHeight();
1029						}
1030						pagemiddle = Math.floor( pagemiddle + ( offset / 2) );
1031						b.attr('data-scrollspy-half',pagemiddle);
1032						o.scrollspycontainer.find("a[href^='#']").each(function(i,c){
1033							var link = $(c),
1034								to,
1035								hash = link.attr('href'),
1036								section = $(hash);
1037							if(section.length > 0){
1038								var top = Math.floor(section.offset().top),
1039									bottom = top + Math.floor(section.outerHeight()),
1040									middle = (top + ((bottom - top) / 2)),
1041									to = top - offset;
1042								section.attr('data-scrollspy-mid', middle);
1043								if(cando){ // No Edge
1044									link.unbind('click')
1045									.off('click')
1046									.on('click', function(e){
1047										e.preventDefault();
1048										window.scrollTo({
1049										  top: to,
1050										  left: 0,
1051										  behavior: 'smooth'
1052										});
1053										return false;			
1054									});
1055								}
1056							}
1057						});
1058					}
1059					var initScroll = setTimeout( qtScrollSpyInit ,600);
1060				},
1061				update: function(st){
1062					var o = $.ProRadioMainObj,
1063						b = o.body,
1064						hp = Number(b.attr('data-scrollspy-half')),
1065						s = $('[data-scrollspy-mid]'),
1066						d, a = [], link,
1067						timeout = false,
1068						menu = $("#proradio-stickycon");
1069					s.each(function(i,c){
1070						var t = $(c),
1071						d = Math.abs( ( Number(t.attr('data-scrollspy-mid')) - st) - hp );
1072						a.push(
1073							[d,t.attr('id')]
1074						);
1075					}); 
1076					a.sort(function(a,b) {
1077						return a[0]-b[0]
1078					});
1079					if(undefined !== a[0]){
1080						link = a[0][1];
1081						if(timeout){
1082							clearTimeout(timeout);
1083						}
1084						timeout = setTimeout(function(o){
1085							menu.find('.proradio-active').removeClass('proradio-active');
1086							menu.find('a[href="#'+link+'"]').addClass('proradio-active');
1087						}, 30);
1088					}
1089				}
1090			},
1091
1092
1093			/* Owl
1094			====================================================================*/
1095			bannerCarouselHasBeenInitialized: function(event) {
1096				// Provided by the core
1097				var element   = event.target;         // DOM element, in this example .owl-carousel
1098				var name      = event.type;           // Name of the event, in this example dragged
1099				var namespace = event.namespace;      // Namespace of the event, in this example owl.carousel
1100				var items     = event.item.count;     // Number of items
1101				var item      = event.item.index;     // Position of the current item
1102				// Provided by the navigation plugin
1103				var pages     = event.page.count;     // Number of pages
1104				var page      = event.page.index;     // Position of the current page
1105				var size      = event.page.size;      // Number of items per page
1106			},
1107			owlCarousel: function(targetContainer){
1108				if(!jQuery.fn.owlCarousel) { return; }
1109				if(undefined === targetContainer) { targetContainer = "body"; }
1110
1111				var that = $(this);
1112
1113				function waitAndInitOwl(T, c, selectorId){
1114					var tries = 0;
1115					var maxTries = 120; // ~2s @ 60fps
1116
1117					function readyToMeasure(){
1118						if(!document.body.contains(T[0])) { return false; }
1119						if(!T.is(':visible')) { return false; }
1120						if(T[0].getBoundingClientRect().width < 10) { return false; }
1121						return true;
1122					}
1123
1124					function init(){
1125						// console.log('Owl new');
1126						// prevent double init
1127						if(T.hasClass('owl-loaded') || T.hasClass('proradio-carousel-created')) { return; }
1128
1129						T.owlCarousel({
1130							loop: T.data('loop'),
1131							margin: T.data('gap'),
1132							nav: T.data('nav'),
1133							dots: T.data('dots'),
1134							navText: ['<i class="proradio-arrow proradio-arrow__l"></i>', '<i class="proradio-arrow proradio-arrow__r"></i>'],
1135							center: T.data('center'),
1136							stagePadding: T.data('stage_padding'),
1137							autoplay:  T.data('autoplay_timeout') > 0,
1138							autoplayTimeout: T.data('autoplay_timeout'),
1139							autoplayHoverPause: T.data('pause_on_hover'),
1140							callbacks: true,
1141							mouseDrag: true,
1142							touchDrag: false,
1143							navSpeed: 600,
1144							autoplaySpeed: 1500,
1145							responsive:{
1146								0:{items:T.data('items_mobile'),mouseDrag:false,touchDrag:true},
1147								480:{items:T.data('items_mobile_hori'),mouseDrag:false,touchDrag:true},
1148								600:{items:T.data('items_tablet'),mouseDrag:false,touchDrag:true},
1149								1025:{items:T.data('items')},
1150								1200:{items:T.data('items'),mouseDrag:true,touchDrag:true}
1151							},
1152							onInitialized:function(){
1153								T.addClass('proradio-carousel-created');
1154								
1155								that[0].activatesComponent(selectorId);
1156								setTimeout(function(){
1157									$(c).fadeTo(1, 1);
1158								},500);
1159							
1160								// if first slide has images, refresh after they load to stabilize height/width
1161								var imgs = T.find('img');
1162								if(imgs.length){
1163									var pending = 0;
1164									imgs.each(function(){
1165										if(!this.complete){
1166											pending++;
1167											$(this).one('load error', function(){
1168												pending--;
1169												if(pending <= 0){
1170													T.trigger('refresh.owl.carousel');
1171												}
1172											});
1173										}
1174									});
1175									if(pending === 0){
1176										T.trigger('refresh.owl.carousel');
1177									}
1178								}
1179							},
1180							onRefreshed:function(){
1181								that[0].qtWaypoints.reinitialize();
1182								that[0].qtWaypoints.update( $.ProRadioMainObj.scrolledTop );
1183							}
1184						});
1185					}
1186
1187					setTimeout(function(){
1188						(function loop(){
1189							if(readyToMeasure()){ 
1190								init(); return; 
1191							}
1192							if(++tries >= maxTries){ 
1193								init();
1194								return;
1195							} // last resort
1196							requestAnimationFrame(loop);
1197						})();
1198					},350);
1199				}
1200
1201				$(targetContainer+' .proradio-owl-carousel').each(function(i,c){
1202					var T = $(c);
1203					if(!T.hasClass('proradio-carousel-created')){
1204						T.fadeTo(0);
1205					}
1206					var selectorId = '#'+T.attr('id');
1207					waitAndInitOwl(T, c, selectorId);
1208					if( T.hasClass('proradio-multinav-main')) {
1209						controllerTarget = T.data('target');
1210						T.parent().find('.proradio-multinav__controller').find('a:first-child').addClass('current');
1211						T.on('changed.owl.carousel', function (e) {
1212							if (e.item) {
1213								itemIndex = T.find('.active [data-index]').data('index') + 1;
1214								var index = e.item.index,
1215									count = e.item.count;
1216								if (index > count) {
1217									index -= count;
1218								}
1219								if (index <= 0) {
1220									index += count;
1221								}
1222								T.parent().find('.proradio-multinav__controller .current').removeClass('current');
1223								T.parent().find('.proradio-multinav__controller').find('[data-multinav-controller="'+itemIndex+'"]').addClass('current');
1224							}
1225						});
1226					}
1227					T.on('click', "[data-multinav-controller]", function(e){
1228						e.preventDefault();
1229						var t = $(this),
1230							i = t.data("multinav-controller"),
1231							targ = t.data("multinav-target");
1232						$('#'+targ).trigger('stop.owl.autoplay', i);
1233						$('#'+targ).trigger('to.owl.carousel', i);
1234						T.parent().find('.proradio-multinav__controller .owl-item a').removeClass('current');
1235						t.addClass('current');
1236					});
1237				});
1238			},
1239
1240
1241
1242
1243
1244
1245
1246			/*owlCarouselOld: function(targetContainer){
1247				if(!jQuery.fn.owlCarousel) {
1248					return;
1249				}
1250				if(undefined === targetContainer) {
1251					targetContainer = "body";
1252				}
1253				var that = $(this);
1254				$(targetContainer+' .proradio-owl-carousel').each( function(i,c){
1255					var T = $(c),
1256						idc = $(c).attr("id"),
1257						itemIndex,
1258						controllerTarget;
1259					if(!T.hasClass('proradio-carousel-created')){
1260						T.fadeTo(0);
1261					}
1262					var selectorId =  '#'+T.attr('id');
1263					var LoadDelay = 500; // needs to be at least 500 or it's not displaying fine
1264					if( T.data('loop') ){
1265						LoadDelay = 500;
1266					}
1267					var init = function () {
1268						T.owlCarousel({
1269							loop: T.data('loop'),
1270							margin: T.data('gap'),
1271							nav: T.data('nav'),
1272							dots: T.data('dots'),
1273							navText: ['<i class="proradio-arrow proradio-arrow__l"></i>', '<i class="proradio-arrow proradio-arrow__r"></i>'],
1274							center: T.data('center'),
1275							stagePadding: T.data('stage_padding'),
1276							autoplay:  T.data('autoplay_timeout') > 0,
1277							autoplayTimeout: T.data('autoplay_timeout'),
1278							autoplayHoverPause: T.data('pause_on_hover'),
1279							callbacks: true,
1280							mouseDrag: true,
1281							touchDrag: false,
1282							navSpeed: 600,
1283							autoplaySpeed: 1500,
1284							responsive:{
1285								0:{
1286									items: T.data('items_mobile'),
1287									mouseDrag: false,
1288									touchDrag: true
1289								},
1290								480:{
1291									items: T.data('items_mobile_hori'),
1292									mouseDrag: false,
1293									touchDrag: true
1294								},
1295								600:{
1296									items: T.data('items_tablet'),
1297									mouseDrag: false,
1298									touchDrag: true
1299								},
1300								1025:{
1301									items: T.data('items'),
1302								},
1303								1200:{
1304									items: T.data('items'),
1305									mouseDrag: true,
1306									touchDrag: true
1307								}
1308							},
1309							onInitialized:function(){
1310
1311								T.addClass('proradio-carousel-created');
1312								that[0].activatesComponent( selectorId );
1313								$(c).fadeTo(1, 1);
1314							},
1315						});
1316					};
1317					requestAnimationFrame(init);
1318					if( T.hasClass('proradio-multinav-main')) {
1319						controllerTarget = T.data('target');
1320						T.parent().find('.proradio-multinav__controller').find('a:first-child').addClass('current');
1321						T.on('changed.owl.carousel', function (e) {
1322							if (e.item) {
1323								itemIndex = T.find('.active [data-index]').data('index') + 1;
1324								var index = e.item.index,
1325									count = e.item.count;
1326								if (index > count) {
1327									index -= count;
1328								}
1329								if (index <= 0) {
1330									index += count;
1331								}
1332								T.parent().find('.proradio-multinav__controller .current').removeClass('current');
1333								T.parent().find('.proradio-multinav__controller').find('[data-multinav-controller="'+itemIndex+'"]').addClass('current');
1334							}
1335						});
1336					}
1337					T.on('click', "[data-multinav-controller]", function(e){
1338						e.preventDefault();
1339						var t = $(this),
1340							i = t.data("multinav-controller"),
1341							targ = t.data("multinav-target");
1342						$('#'+targ).trigger('stop.owl.autoplay', i);
1343						$('#'+targ).trigger('to.owl.carousel', i);
1344						T.parent().find('.proradio-multinav__controller .owl-item a').removeClass('current');
1345						t.addClass('current');
1346					});
1347				});
1348			},*/
1349
1350			/*Display a single map (requires related js and plugin to work)
1351			====================================================================*/
1352			displayMap: function(){
1353				if( 'object' !== typeof( google )){ return; }
1354				if( 'object' !== typeof( google.maps )){ return; }
1355				if( 'function' !== typeof( google.maps.Map )){ return; }
1356				$('[data-proradio-mapcoord]').each(function(i,c){
1357					var that = $(c),
1358						coords = that.attr('data-proradio-mapcoord').split(','),
1359						mapcontainer = that,
1360						id = that.attr('id');
1361					if($.ProRadioMainObj.fn.isMobile()){
1362						that.height(400);
1363					} else {
1364						that.height(600);
1365					}
1366					var myLatlng = new google.maps.LatLng(coords[0], coords[1]);
1367					var mapOptions = {
1368					  zoom: 16,
1369					  center: myLatlng,
1370					};
1371					var themap = new google.maps.Map(document.getElementById(id),mapOptions);
1372					var marker = new google.maps.Marker({position: {lat: parseFloat(coords[0]), lng: parseFloat(coords[1])}, map: themap});
1373				});
1374			},
1375
1376			/* Sticky sidebar
1377			====================================================================*/
1378			stickySidebar: function  (){
1379				if('function' === typeof( $.fn.ttgStickySidebar ) && false === $.ProRadioMainObj.fn.isMobile()){
1380					$('.proradio-stickycol').each(function(i,c){
1381						var that = $(c),
1382							contSelector = '.proradio-stickycont',
1383							container = that.closest( contSelector ),
1384							randid = $.ProRadioMainObj.fn.uniqId();
1385						if(!container.attr('id')){
1386							container.attr('id', randid);
1387						}
1388						contSelector = container.attr('id');
1389						that.ttgStickySidebar({
1390							containerSelector: contSelector,
1391							additionalMarginTop: 200,
1392							additionalMarginBottom: 20,
1393							updateSidebarHeight: true,
1394							minWidth: 678
1395						});
1396					});
1397				}
1398			},
1399
1400			/**
1401			 * Water waves effect headers
1402			 */
1403			qtWaterwaveInit: function(){
1404				setTimeout(
1405					function(){
1406						$('.proradio-waterwave__canvas').each(function(i,c){
1407							var t = $(c);
1408							t.css({bottom: '-100%'});
1409							var wv = t.waterwave({
1410								parent: t.parent(),
1411								speed: t.data('waterwave-speed') || 1,
1412								color: t.data('waterwave-color') || '#ffffff',
1413								background:  t.data('waterwave-background') || '' // image
1414							}).delay(5).promise().done(function(){
1415								t.animate({bottom:"0%"}, 600);
1416							});
1417						});
1418					},
1419					100
1420				);
1421			},
1422
1423
1424
1425			/**
1426			 * Custom styles from shortcodes
1427			 */
1428			customStylesHead: function(){
1429				var styles = '';
1430				$('[data-proradio-customstyles]').each(function(i,c){
1431					styles = styles + $(c).data('proradio-customstyles');
1432				});
1433				$('#proradio-customstyles').remove();
1434				$('head').append('<style id="proradio-customstyles">'+styles+'<style>');
1435				// Also, fix viewport as if scalable will break performance and 3d
1436				$('[name="viewport"]').attr('content', 'width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0');
1437			},
1438
1439			/**
1440			 * Close the off canvas menu
1441			 */
1442			resetOverlay: function(){
1443				$('.proradio-overlayopen').removeClass('proradio-overlayopen');
1444			},
1445
1446			/**
1447			 * Close off canvas menu if clicking an internal link
1448			 */
1449			internalLinkClose : function(){
1450				$('#proradio-overlay .proradio-menu-tree a').on('click',function(e){
1451					var href = $(this).attr('href');
1452					// Since 2019 04 18 + support internal links
1453					var pageURL = $(location).attr("href"),
1454						pageURL_array = pageURL.split('#'),
1455						pageURL_naked = pageURL_array[0],
1456						href_array = href.split('#'),
1457						href_naked = href_array[0];
1458
1459					if(href_naked === pageURL_naked) {
1460						$.ProRadioMainObj.fn.resetOverlay();
1461						return e;
1462					}
1463				})
1464				
1465			},
1466
1467			/**====================================================================
1468			 *
1469			 *
1470			 *	Masonry templates (based on default Wordpress Masonry)
1471			 *
1472			 * 
1473			 ====================================================================*/
1474			qtMasonry: function(targetContainer){
1475				if(undefined === targetContainer) {
1476					targetContainer = "body";
1477				}
1478				$(targetContainer).find('.qt-masonry').imagesLoaded().then(
1479					function(){
1480						var $grid = $('.qt-masonry').masonry(
1481							{  
1482								itemSelector: '.qt-ms-item',  
1483								columnWidth: '.qt-ms-item',
1484							}
1485						);
1486					}
1487				);
1488				$(targetContainer).find('.gallery').each(function(){
1489					var gallery = $(this);
1490					if(gallery.parent().hasClass('elementor-image-gallery')){
1491						return;
1492					}
1493					gallery.imagesLoaded().then(
1494						function(){
1495							var $grid = $('.gallery').masonry(
1496							 {  itemSelector: '.gallery-item',  
1497							  columnWidth: '.gallery-item', 
1498							  gutter: 10
1499							} );
1500						}
1501					);
1502				});
1503				return true;
1504			},
1505
1506
1507			autoloadMore: function(){
1508				$(window).on('resize scroll', function() {
1509					$('.proradio-autoloadMore').each(function(i,c){
1510						var elementTop = $(c).offset().top;
1511						var elementBottom = elementTop + $(c).outerHeight();
1512						var viewportTop = $(window).scrollTop();
1513						var viewportBottom = viewportTop + $(window).height();
1514						if( elementTop < (viewportBottom + 300) ){
1515							$(c).click().remove();
1516						}
1517					});
1518				});
1519			},
1520
1521			
1522			loadmore: function(){
1523				var ob = $.ProRadioMainObj,
1524					body = ob.body,
1525					f = ob.fn,
1526					container , // container
1527					paginationButton = '[data-proradio-loadmore]',
1528					selectorId,
1529					button,
1530					link,
1531					pagination,
1532					list;
1533				body.off('click',paginationButton);
1534				body.on('click',paginationButton, function(e){
1535					e.preventDefault();
1536					button = $(this);
1537					link = button.attr('href');
1538					selectorId = button.data("proradio-loadmore");
1539					button.find('i').show();
1540					container = $(selectorId);
1541					button.css({'pointer-events': 'none','opacity': 0.5});
1542					$.ajax({
1543						url: link,
1544						cache:false,
1545						async:true,
1546						success:function(data) {
1547							list = $(selectorId, data);
1548							pagination = container.find('.proradio-wp-pagination');
1549							pagination.fadeTo(250, 0, function(){
1550								pagination.remove();
1551								container.append(list.html());
1552								f.qtWaypoints.reinitialize();
1553								f.qtWaypoints.update( $.ProRadioMainObj.scrolledTop );
1554								f.activatesComponent( selectorId );
1555								f.countDown.init();
1556								if( container.hasClass('qt-masonry') ){
1557									container.masonry('reloadItems').masonry({
1558										itemSelector: '.qt-ms-item',
1559										transitionDuration: 0
1560									});
1561								}
1562							});
1563						},
1564						error: function () {
1565							window.location.replace(link);
1566						}
1567					});
1568
1569					e.stopPropagation();// to be tested!
1570				});
1571			},
1572
1573
1574
1575			popupLink: function(){
1576				
1577				$(".proradio-popupwindow, .qt-popupwindow").off("click").on("click", function(e){
1578					
1579					e.preventDefault();
1580					
1581					var settings, parameters, mysettings, b, a, winObj;
1582					// for overrideing the default settings
1583					var btn = $(this),
1584						destination = btn.attr("href"),
1585						name = btn.attr("data-name"),
1586						width= btn.attr("data-width"),
1587						height= btn.attr("data-height");
1588
1589					// @since 1.4.3
1590					// Stop audio if open the popup
1591					if( /proradio\-popup/i.test(destination)){
1592						if('object' === typeof($.qtPlayerObj)){
1593							var o = $.qtPlayerObj;
1594							var p = o.uniPlayer;
1595							var i = o.interface;
1596							var b = i.btnPlay;
1597							var state = b.find("i").html();
1598							if(state === 'pause'){
1599								p.pause();
1600							}
1601						}
1602					}
1603
1604					settings = {
1605						height:600, // sets the height in pixels of the window.
1606						width:600, // sets the width in pixels of the window.
1607						toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
1608						scrollbars:1, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
1609						status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
1610						resizable:1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
1611						left:0, // left position when the window appears.
1612						top:0, // top position when the window appears.
1613						center:0, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
1614						createnew:1, // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
1615						location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
1616						menubar:0, // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
1617						onUnload:null // function to call when the window is closed
1618					};
1619					if(width) {
1620						settings.width = width;
1621					}
1622					if(height) {
1623						settings.height = height;
1624					}
1625					// center the window
1626					if (settings.center == 1)
1627					{
1628						settings.top = (screen.height-(settings.height + 110))/2;
1629						settings.left = (screen.width-settings.width)/2;
1630					}
1631
1632					parameters = "location=" + settings.location + ",menubar=" + settings.menubar + ",height=" + settings.height + ",width=" + settings.width + ",toolbar=" + settings.toolbar + ",scrollbars=" + settings.scrollbars  + ",status=" + settings.status + ",resizable=false,left=" + settings.left  + ",screenX=" + settings.left + ",top=" + settings.top  + ",screenY=" + settings.top;
1633					winObj = window.open(destination, name, parameters);
1634				
1635					
1636
1637					e.stopPropagation();
1638					return false;
1639				});
1640			},
1641
1642
1643			/**====================================================================
1644			 *
1645			 * 
1646			 *  Ajax elements refresh
1647			 *  
1648			 * 
1649			 ====================================================================*/
1650			 runAutoRefreshWidgets: function(f) {
1651
1652				/**
1653				 * Since 9.5
1654				 * Respect the global auto-refresh setting before doing anything.
1655				 *
1656				 * Empty or 0 = disabled.
1657				 * Positive value = enabled.
1658				 *
1659				 * Use attr() instead of data() here so an explicitly empty
1660				 * attribute can be distinguished correctly.
1661				 */
1662				var autoRefreshSetting = $('body').attr('data-proradio-autorefreshenabled');
1663
1664				if (typeof autoRefreshSetting !== 'undefined') {
1665
1666					autoRefreshSetting = $.trim(String(autoRefreshSetting));
1667
1668					if (autoRefreshSetting === '') {
1669						f.doDebug('runAutoRefreshWidgets: Disabled - empty setting');
1670						return;
1671					}
1672
1673					autoRefreshSetting = parseInt(autoRefreshSetting, 10);
1674
1675					if (isNaN(autoRefreshSetting) || autoRefreshSetting <= 0) {
1676						f.doDebug('runAutoRefreshWidgets: Disabled');
1677						return;
1678					}
1679				}
1680
1681
1682				var link = window.location.href;
1683				link = new URL(link);
1684
1685				var dt = new Date();
1686				var time = dt.getHours() + "-" + dt.getMinutes() + "-" + dt.getSeconds();
1687
1688				link.searchParams.append('nocache', time);
1689				link = link.toString();
1690
1691				var idsToRefresh = [];
1692				var speed = 1;
1693
1694
1695				/**
1696				 * IMPORTANT:
1697				 * data-proradio-autorefresh is the marker identifying
1698				 * widgets that are refreshable.
1699				 *
1700				 * Do NOT filter these elements based on the value of
1701				 * data-proradio-autorefresh.
1702				 */
1703				if ($('body').hasClass('proradio-cache_fix')) {
1704
1705					speed = 200;
1706
1707					$('[data-proradio-autorefresh]')
1708						.closest('div')
1709						.parent()
1710						.append('<i class="material-icons proradio-autoref">data_usage</i>');
1711				}
1712
1713
1714				$('[data-proradio-autorefresh]').each(function(i, c) {
1715
1716					var item = $(c);
1717
1718					// Fix for widgets without an ID
1719					if (!item.attr('id')) {
1720
1721						var parentId = item
1722							.closest('[data-elementor-id]')
1723							.data('elementor-id');
1724
1725						if (parentId) {
1726							item.attr('id', parentId + '-proradio-torefresh');
1727						} else {
1728							item.css({'opacity': 1});
1729						}
1730					}
1731
1732					// Never add an undefined ID to the refresh list.
1733					if (item.attr('id')) {
1734						idsToRefresh.push(item.attr('id'));
1735					}
1736				});
1737
1738
1739				if (idsToRefresh.length <= 0) {
1740					return;
1741				}
1742
1743
1744				$.ajaxSetup({
1745					cache: false
1746				});
1747
1748
1749				$.ajax({
1750					url: link,
1751					cache: false,
1752
1753					success: function(data) {
1754
1755						$.each(idsToRefresh, function(i, id) {
1756
1757							var theselector = '#' + id;
1758							var item = $(theselector);
1759							var newData = $(data).find(theselector);
1760
1761							// Only replace the widget if it actually exists
1762							// in the returned page.
1763							if (newData.length > 0) {
1764
1765								var newHtml = newData.html();
1766
1767								item.animate({opacity: 0}, 10, function() {
1768
1769									item.html(newHtml)
1770										.delay(10)
1771										.promise()
1772										.done(function() {
1773
1774											f.activatesComponent(theselector);
1775											f.qtWaypoints.reinitialize();
1776											f.qtWaypoints.update($.ProRadioMainObj.scrolledTop);
1777											f.tabsComponent(theselector);
1778											f.owlCarousel(theselector);
1779
1780											item.animate({opacity: 1}, speed);
1781
1782											f.glitchPics.init(f, theselector);
1783										});
1784								});
1785							}
1786						});
1787
1788
1789						$('body').removeClass('proradio-cache_fix');
1790						$('.proradio-autoref').remove();
1791
1792						$('.proradio-activeschedule .proradio-post[data-qtwaypoints]')
1793							.css({opacity: 1});
1794					},
1795
1796					error: function(e) {
1797
1798					}
1799				});
1800
1801
1802				f.doDebug(
1803					"END OF widgetsRefresh ======================================================="
1804				);
1805			},
1806
1807			wrInterval: false,
1808			widgetsRefresh: function(f) {
1809				if ($('body').hasClass('elementor-editor-active')) {
1810					return;
1811				}
1812				if (typeof f.wrInterval !== 'undefined' && f.wrInterval !== false) {
1813					f.doDebug('widgetsRefresh: Clear existing interval');
1814					clearInterval(f.wrInterval);
1815				}
1816				f.doDebug('START - widgetsRefresh: Initialized');
1817				if ($('body').hasClass('proradio-cache_fix')) {
1818					f.runAutoRefreshWidgets(f);
1819				}
1820				let interval = 60000;  // Default interval
1821				let customInterval = $('body').data('proradio-autorefreshenabled');
1822				f.doDebug('Custom Interval: ' + customInterval);
1823				if (typeof customInterval !== 'undefined' && customInterval !== '') {
1824					customInterval = parseInt(customInterval, 10);
1825					if (isNaN(customInterval) || customInterval <= 0) {
1826						f.doDebug('widgetsRefresh: Disable refresh');
1827						return;
1828					}
1829					interval = Math.max(customInterval, 60) * 1000;  // Ensure minimum interval of 60 seconds ====================================================================================
1830				}
1831				f.doDebug(`Final Interval: ${interval}`);
1832				f.wrInterval = setInterval(function() {
1833					f.doDebug('widgetsRefresh: Triggering auto-refresh');
1834					f.runAutoRefreshWidgets(f);
1835				}, interval);
1836			},
1837			
1838			
1839
1840			/* Theme clock: perform some actions at some interval
1841			====================================================================*/
1842			themeScroll: function(){
1843				var o = $.ProRadioMainObj,
1844					f = o.fn,
1845					st, 
1846					os,
1847					timer = o.clockTimer;
1848				if( f.isMobile() ){
1849					timer = o.clockTimerMobile; 
1850				}
1851
1852				if(o.clock !== false){
1853					clearInterval( o.clock );
1854				}
1855				o.body.attr('data-proradio-scrolled', 0);
1856				o.clock = setInterval(
1857					function(){
1858						f.scrolledTop(); 
1859						st = o.scrolledTop;
1860						os = o.oldScroll;
1861						if( os !== st  ){
1862							o.oldScroll = st;
1863							f.stickyBarLink(st);
1864							o.body.attr('data-proradio-scrolled', st);
1865							f.qtScrollSpy.update(st);
1866							f.qtWaypoints.update(st);
1867							f.stickyMenu.trackScroll(st, os);
1868							// if(st > (os + 30) ) {
1869							// 	f.stickyMenu.pageScrolled(st, 'down');
1870							// }
1871							// if(st < (os - 30) && st < 400 ){
1872							// 	f.stickyMenu.pageScrolled(st, 'up');
1873							// }
1874						}
1875					},timer
1876				);
1877			},
1878
1879			collapsibleWrapper: function(){
1880				if( 'function' === typeof( $.fn.collapsible ) ){
1881					$('.qt-collapsible').collapsible();
1882				}
1883			},
1884
1885
1886
1887
1888			/* Trigger custom functions on window resize, with a delay for performance enhacement
1889			====================================================================*/
1890			windowResized: function(f){
1891				var rst,
1892					w = $(window);
1893				f.wW = w.width();
1894				f.wH = w.height();
1895				w.on('resize', function(e) {
1896					clearTimeout(rst);
1897					rst = setTimeout(function() {
1898						f.qtScrollSpy.init();
1899						f.qtWaypoints.reinitialize();
1900						f.menuItemAlign();
1901						f.owlCarousel();
1902						f.qtWaterwaveInit();
1903						f.qtMasonry();
1904						f.qtParallax();
1905						if (w.height() != f.wH) {
1906							f.stickyBarLinkPrep();
1907							f.themeScroll();		
1908							f.widgetsRefresh(f);
1909							// Scrollbar.init(document.querySelector('#proradio-global'), options);
1910						}
1911						if (w.width() != f.wW){
1912							f.stickyBarLinkPrep();
1913							f.YTreszr();
1914						}
1915					}, 500);
1916				});
1917			},
1918
1919			
1920
1921			/**
1922			 * ====================================================================
1923			 *  3D elements append listeners
1924			 * ====================================================================
1925			 */
1926			
1927			
1928			fx3dElements: {
1929				init: function( proradio ){
1930					$(document).off('mousemove.fx3dElements');
1931					var $doc = proradio.document;
1932					var $win = window;
1933					var screenWidth = $win.screen.width / 2,
1934						screenHeight = $win.screen.height / 2,
1935						validPropertyPrefix = '',
1936						otherProperty = 'perspective(800px)';
1937					if( $.ProRadioMainObj.fn.isMobile() ){
1938						return;
1939					}
1940					if( $('.proradio-3dheader__contents__caption').length <= 0 && $('.proradio-fx-3dheader').length <= 0 ){
1941						return;
1942					}
1943					$('.proradio-3dheader__contents__caption, .proradio-3dheader__bg--1, .proradio-3dheader__bg--2, .proradio-fx-3dheader:not(.single-qtvideo) .proradio-pageheader__contents .proradio-container ').css({ 'transform': "translate3D(0px, 0px, -0.001px)" });
1944					$(document).on('mousemove.fx3dElements', function (e) {
1945						var centroX = e.clientX - screenWidth,
1946							centroY = screenHeight - (e.clientY + 13),
1947							degX = centroX * 0.015,
1948							degY = centroY * 0.008;
1949						$('.proradio-3dheader__contents__caption,  .proradio-fx-3dheader:not(.single-qtvideo) .proradio-pageheader__contents .proradio-container ').css({ 
1950							'transform' : otherProperty + ' rotateY('+ degX * 0.5 +'deg)  rotateX('+ degY  +'deg)' ,
1951						});
1952						$('.proradio-3dheader__bg--1').css({"transform": "translate(" + degX + "px, " + degY * - 1 + "px)"},30);
1953						$('.proradio-3dheader__bg--2').css({"transform": "translate(" + degX * -1 + "px, " + degY  + "px)"},30);
1954					});
1955				},
1956			},
1957
1958
1959			/**
1960			 * ====================================================================
1961			 * Glitch picture
1962			 * ====================================================================
1963			 */
1964			glitchPics: {
1965				init: function( f, targetContainer ){
1966					if(undefined === targetContainer) {
1967						targetContainer = "body";
1968					}
1969					if(!$("#proradio-body").hasClass('proradio-fx-glitch')){
1970						return;
1971					}
1972					$(targetContainer +' .proradio-post .proradio-bgimg').each(function(){
1973						var t = $(this);
1974						var imgurl = t.find('img:first-child').attr('src');
1975						var classes = t.find('img').attr('class');
1976						t.find('.proradio-imgfx--glitch__f1').remove('.proradio-imgfx--glitch__f2').remove();
1977						if (typeof imgurl === 'string' && !/\/undefined(\?|$)/.test(imgurl)) {
1978							t.append('<img src="'+imgurl+'" class="proradio-imgfx--glitch__f1 '+classes+'"><img src="'+imgurl+'" class="proradio-imgfx--glitch__f2 '+classes+'">');
1979						}
1980					});
1981
1982					f.window.off('viceGlitchStart.viceimgglitch').off('viceGlitchStop.viceimgglitch');
1983					f.window.on('viceGlitchStart.viceimgglitch', function(){
1984						$('.proradio-post').addClass('fx-on');
1985					});
1986					f.window.on('viceGlitchStop.viceimgglitch', function(){
1987						$('.proradio-post').removeClass('fx-on');
1988					});
1989				}
1990			},
1991
1992			/**
1993			 * ====================================================================
1994			 * Global glitch automation loop
1995			 * ====================================================================
1996			 */
1997			glitchLoop: {
1998				state: 0,
1999				newstate: 0,
2000				init: function( f ){
2001					var that = this;
2002					var arrogance = 15;//$('[data-vice-glitch-arrogance]').data('vice-glitch-arrogance');
2003					if( !arrogance ){
2004						arrogance = 15;
2005					}
2006					arrogance = 1 - ( arrogance / 100 );
2007					if( 'undefined' !== typeof( that.glitchInterval  ) ){
2008						clearInterval( that.glitchInterval );
2009					}
2010					that.glitchInterval = setInterval(
2011						function(){
2012							that.newstate = 0;
2013							if( Math.random() > arrogance){ // the hightr the limit it, the less it glitches. Chance or probability to glitch
2014								that.newstate = 1;
2015							}
2016							// act only if it changes
2017							if( that.newstate !== that.state ){
2018								that.state = that.newstate;
2019								if( that.state ){
2020									f.window.trigger('viceGlitchStart');
2021								}else {
2022									f.window.trigger('viceGlitchStop');
2023								}
2024								
2025							}
2026						}, 500
2027					);
2028				}
2029			},
2030			
2031
2032
2033			/**
2034			 * ====================================================================
2035			 *  offCanvasWypointFix
2036			 *  * Fix waypoint items added in the OffCanvas element
2037			 * ====================================================================
2038			 */
2039			offCanvasWypointFix: function(){
2040				$('#proradio-sidebar-offcanvas [data-qtwaypoints]').addClass('proradio-active');
2041			},
2042
2043
2044			/**
2045			 * ====================================================================
2046			 *  ajaxCommentsForm
2047			 *  
2048			 * ====================================================================
2049			 */
2050			ajaxCommentsForm: function(){
2051				if(!$('body').hasClass('proradio-ajax-comments')){
2052					return;
2053				}
2054				var commentform = $('#proradio-commentform');
2055				  commentform.prepend('<div id="comment-status" ></div>');
2056					var statusdiv=$('#comment-status');
2057					commentform.on('submit', function(){
2058					  var formdata=commentform.serialize();
2059					  statusdiv.html('<p class="ajax-placeholder">Processing...</p>');
2060					  var formurl=commentform.attr('action');
2061					  $.ajax({
2062						type: 'post',
2063						url: formurl,
2064						data: formdata,
2065						error: function(XMLHttpRequest, textStatus, errorThrown){
2066						  statusdiv.html('<p class="proradio-comment-ajax-error">You might have left one of the fields blank, or be posting too quickly</p>');
2067						},
2068						success: function(data, textStatus){
2069							
2070							if(textStatus == "success"){
2071								statusdiv.html('<p class="proradio-comment-ajax-success">Thanks for your comment, please hold on while we review it.</p>');
2072							} else {
2073								statusdiv.html('<p class="proradio-comment-ajax-error" >Please wait a while before posting your next comment</p>');
2074								 commentform.find('textarea[name=comment]').val('');
2075							}
2076							// Reload the comments list
2077							var reloadUrl = new URL(window.location.href);
2078							reloadUrl.searchParams.append('nocache', Math.floor(Math.random() * (100 - 50)) + 50);
2079							$.ajax({
2080							   url: reloadUrl,
2081							   type:'GET',
2082							   success: function(data){
2083								   $('#comments .proradio-comment-list').html($(data).find('#comments .proradio-comment-list').html());
2084							   },error: function(XMLHttpRequest, textStatus, errorThrown){
2085									console.log('Error fetching the comments list'+errorThrown);
2086								}
2087							});
2088						}
2089					  });
2090					  return false;
2091				  });
2092			},
2093
2094
2095			/**====================================================================
2096			 *
2097			 * 
2098			 *  Marquee for longer texts
2099			 *  
2100			 * 
2101			 ====================================================================*/
2102			marqueeInstances: [],
2103			marqueeText: function(that) {
2104				
2105				if('function' !== typeof( $.fn.marquee ) ){ // missing marquee library? quit
2106					return;
2107				}
2108				var marquees = $('body').find('.proradio-text-marquee');
2109
2110				// Destroy any old instance of the marquee
2111				if( that.marqueeInstances.length > 0 ){
2112					for( var mi = 0; mi < that.marqueeInstances.length; mi++ ){
2113						if( 'undefined' !== typeof( that.marqueeInstances[mi] )){
2114							that.marqueeInstances[mi].marquee('destroy');
2115						}
2116					}
2117					that.marqueeInstances = []; // reset
2118				}
2119				$.each(marquees, function(i,c){
2120					var item = $(c);
2121					if(item.find('.marquee').length === 0){
2122						item.html('<span class="marquee">'+item.html()+'</span>');
2123					}
2124					var direction = 'left';
2125					if(item.hasClass('vertical')){
2126						 direction = 'up';
2127					}
2128
2129					that.marqueeInstances[i] = item.marquee({
2130						gap: 10,
2131						delayBeforeStart: 0,
2132						// pauseOnHover: 1,
2133						pauseOnCycle: 0,
2134						startVisible: true
2135					});
2136				});
2137			},
2138
2139			/**====================================================================
2140			 *
2141			 * 
2142			 *  Particles
2143			 *  
2144			 * 
2145			 ====================================================================*/
2146			particles: function(){
2147				var url = $('#proradio-components-particle-url').data('proradio-component-url');
2148				//$('.proradio-pageheader-container .proradio-particles-js').each(function(i,c){
2149				$('#proradio-header-particles-js').each(function(i,c){
2150					var id 		= $(c).attr('id');
2151					var style 	= $(c).data('proradio-particles-style') ? $(c).data('proradio-particles-style') : 'cfg-default';
2152					if( 'undefined' !== typeof(particlesJS) ){
2153						particlesJS.load(id, url + style + '.json', function() {
2154						});
2155					}
2156				});
2157			},
2158
2159
2160			proradioCF7GuardInit: function () {
2161				$('.wpcf7 form').each(function () {
2162					var $form = $(this);
2163					if ($form.data('pr-guard-bound')) return;
2164
2165					var $widget = $form.find('.proradio-cf7-as');
2166					if (!$widget.length) return;
2167
2168					$form.data('pr-guard-bound', true);
2169
2170					var $submit = $form.find('input.wpcf7-submit, button.wpcf7-submit, input[type="submit"], button[type="submit"]').first();
2171					if (!$submit.length) return;
2172
2173					// Place widget right before submit
2174					$widget.insertBefore($submit);
2175
2176					var minSec   = parseInt($widget.data('min'), 10) || 10;
2177					var unlockAt = Date.now() + (minSec * 1000);
2178					var $chk     = $widget.find('input[name="proradio_ok"]');
2179					var $cd      = $widget.find('.proradio-as-countdown');
2180
2181					function timeOk() { return Date.now() >= unlockAt; }
2182					function humanOk() { return $chk.prop('checked') === true; }
2183
2184					function updateCountdown() {
2185						var ms = unlockAt - Date.now();
2186						if (ms < 0) ms = 0;
2187						var s = Math.ceil(ms / 1000);
2188						if ($cd.length) $cd.text(s > 0 ? s + 's' : '');
2189					}
2190
2191					function lockSubmit() {
2192						$submit.prop('disabled', true).addClass('is-disabled')
2193							.css({ display: 'none', visibility: 'hidden', pointerEvents: 'none' });
2194						$form.addClass('proradio-form-locked');
2195					}
2196
2197					function unlockSubmit() {
2198						$submit.prop('disabled', false).removeClass('is-disabled')
2199							.css({ display: '', visibility: '', pointerEvents: '' });
2200						$form.removeClass('proradio-form-locked');
2201					}
2202
2203					function updateState() {
2204						if (timeOk() && humanOk()) { unlockSubmit(); } else { lockSubmit(); }
2205					}
2206
2207					// Init
2208					lockSubmit();
2209					updateCountdown();
2210					var timerId = setInterval(function () {
2211						updateCountdown();
2212						updateState();
2213						if (timeOk() && humanOk()) {
2214							clearInterval(timerId);
2215							timerId = null;
2216						}
2217					}, 250);
2218
2219					$chk.on('change.prCF7', updateState);
2220
2221					// Hard block if still locked
2222					$form.on('submit.prCF7', function (e) {
2223						if (!timeOk() || !humanOk()) {
2224							e.preventDefault();
2225							e.stopImmediatePropagation();
2226							updateState();
2227							$chk.focus();
2228						}
2229					});
2230
2231					// Do NOT relock on invalid; only relock on full reset
2232					$form.on('wpcf7reset', function () {
2233						unlockAt = Date.now() + (minSec * 1000);
2234						lockSubmit();
2235						updateCountdown();
2236					});
2237				});
2238			},
2239
2240
2241			/**====================================================================
2242			 *
2243			 *
2244			 * AntiSpam
2245			 *
2246			 * 
2247			 ====================================================================*/
2248
2249
2250			// Call manually on pages with comments: window.proradioCommentGuardInit();
2251			proradioCommentGuardInit: function(){
2252				var $form = $('#proradio-commentform').length ? $('#proradio-commentform') : $('#commentform');
2253				if (!$form.length) return;
2254
2255				// Unbind prior run if form was re-rendered
2256				$form.off('.prCMT');
2257
2258				var $widgets = $form.find('.proradio-cmt-as');
2259				if (!$widgets.length) return;
2260
2261				// Ensure a single widget instance
2262				if ($widgets.length > 1) {
2263					$widgets.not(':first').remove();
2264				}
2265				var $widget = $widgets.first();
2266
2267				// Locate submit and wrapper
2268				var $submit = $form.find('#submit, input[type="submit"], button[type="submit"]').first();
2269				if (!$submit.length) return;
2270
2271				var $wrap = $form.find('.form-submit').first();
2272				if (!$wrap.length) {
2273					$wrap = $submit.closest('p, div, section, .submit');
2274				}
2275
2276				// Place widget immediately before the submit area (no cloning)
2277				if ($wrap.length) { $widget.insertBefore($wrap); } else { $widget.insertBefore($submit); }
2278
2279				var $chk = $widget.find('input[name="proradio_ok"]');
2280
2281				// Preserve original inline styles so we can restore precisely
2282				var origWrapStyle = $wrap.length ? ($wrap.attr('style') || '') : '';
2283				var origBtnStyle  = !$wrap.length ? ($submit.attr('style') || '') : '';
2284
2285				function lock(){
2286					if ($wrap.length) {
2287						$wrap.attr('style', (origWrapStyle ? origWrapStyle + '; ' : '') + 'display:none !important; visibility:hidden; pointer-events:none;');
2288					} else {
2289						$submit.prop('disabled', true).attr('aria-disabled','true')
2290							.attr('style', (origBtnStyle ? origBtnStyle + '; ' : '') + 'display:none !important; visibility:hidden; pointer-events:none;');
2291					}
2292					$form.addClass('proradio-form-locked');
2293				}
2294
2295				function unlock(){
2296					if ($wrap.length) {
2297		                $wrap.attr('style', origWrapStyle);
2298					} else {
2299						$submit.prop('disabled', false).removeAttr('aria-disabled')
2300							.attr('style', origBtnStyle);
2301					}
2302					$form.removeClass('proradio-form-locked');
2303				}
2304
2305				function sync(){
2306					if ($chk.prop('checked')) { unlock(); } else { lock(); }
2307				}
2308
2309				// Initial state: hidden until checked
2310				lock();
2311
2312				// Toggle on change
2313				$chk.on('change.prCMT', sync);
2314
2315				// Allow AJAX comment submitters to run if checked; block only when unchecked
2316				$form.on('submit.prCMT', function(e){
2317					if (!$chk.prop('checked')) {
2318						e.preventDefault();
2319						sync();
2320						$chk.focus();
2321					}
2322				});
2323			},
2324
2325
2326
2327
2328			/**====================================================================
2329			 *
2330			 *	After ajax page initialization
2331			 * 	Used by QT Ajax Pageloader. 
2332			 * 	MUST RETURN TRUE IF ALL OK.
2333			 * 
2334			 ====================================================================*/
2335			initializeAfterAjax: function( is_ajax_reinit  ){
2336				// console.log('initializeAfterAjax');
2337				if (typeof is_ajax_reinit === 'undefined') {
2338				   is_ajax_reinit = false;
2339				}
2340				var f = this;
2341				f.widgetsRefresh(f);
2342				// f.proradioMouseMove.init( f );
2343				f.customStylesHead();
2344				f.marqueeText( f );
2345				f.resetOverlay();
2346				f.qtWaterwaveInit();
2347				f.countDown.init();
2348				f.YTreszr();
2349				f.switchClass();//
2350				f.activatesComponent();//
2351				f.ipadBgFix();
2352				f.fx3dElements.init(f);
2353				f.qtParallax();
2354				f.qtVcVideobg();
2355				f.qtScrollSpy.init();
2356				f.tabsComponent();
2357				f.stickySidebar();
2358				f.displayMap();
2359				f.transformlinks();
2360				f.collapsibleWrapper();
2361				f.qtMasonry();
2362				f.qtWaypoints.reinitialize();
2363				f.offCanvasWypointFix();
2364				f.owlCarousel();//
2365				
2366				f.glitchPics.init( f );
2367				f.ajaxCommentsForm();
2368				f.loadmore();
2369				f.autoloadMore();
2370				f.popupLink();
2371				f.proradioCF7GuardInit();
2372
2373				f.proradioCommentGuardInit();
2374
2375				if("function" === typeof($.fn.qtChartvoteInit)) {
2376					$.fn.qtChartvoteInit();
2377				}
2378				if("function" === typeof($.qtSwipeboxFunction)) {
2379					$.qtSwipeboxFunction();
2380				}
2381				if("function" === typeof jQuery.vdl_Init){
2382					jQuery.vdl_Init();
2383				}
2384				
2385				if("function" === typeof $.fn.qtDynamicMaps){
2386					$.fn.qtDynamicMaps();
2387				}
2388				if("function" === typeof $.fn.qtPlacesInit){
2389					$.fn.qtPlacesInit();
2390				}
2391
2392				var tout = 100;
2393				if( is_ajax_reinit ){
2394					tout = 500;
2395				}
2396				setTimeout(function(){
2397					 f.particles();
2398				},tout);
2399
2400				return true;
2401			},
2402			/**====================================================================
2403			 *
2404			 * 
2405			 *  Functions to run once on first page load
2406			 *  
2407			 *
2408			 ====================================================================*/
2409			init: function() {
2410				var f = this;
2411				if( f.isSafari() ){
2412					$('body').addClass('isSafari');
2413				}
2414				$('html').removeClass('no-js');
2415				f.treeMenu();
2416				f.stickyBarLinkPrep();
2417				f.stickyMenu.init();
2418				f.themeScroll();
2419				f.initializeAfterAjax(f);
2420				f.areClipPathShapesSupported();
2421				f.menuItemAlign();
2422				f.internalLinkClose();
2423				f.windowResized(f);// Always last
2424				if($('.qtmplayer__controllayer_noky').length > 0){
2425					console.error('Please check Pro Radio Player Connection in ProRadio Admin screen');
2426				}
2427			},
2428		}
2429		/**
2430		 * ======================================================================================================================================== |
2431		 * 																																			|
2432		 * 																																			|
2433		 * END SITE FUNCTIONS 																														|
2434		 * 																																			|
2435		 *																																			|
2436		 * ======================================================================================================================================== |
2437		 */
2438	};
2439	
2440	/**====================================================================
2441	 *
2442	 *	Page Ready Trigger
2443	 * 
2444	 ====================================================================*/
2445	jQuery(document).ready(function() {
2446		$.ProRadioMainObj.fn.init();	
2447	});
2448})(jQuery);
2449
2450

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.