PageSourceSearch

https://chinalastnight.com/wp-content/themes/2026_01_14_krane_platform_live/_/js/functions.js?v=46

js chinalastnight.com collected 2026-09-28 10:45:45 UTC 78,300 bytes, 2,406 lines download raw bytes

1// Browser detection for when you get desparate. A measure of last resort.
2// http://rog.ie/post/9089341529/html5boilerplatejs
3
4// var b = document.documentElement;
5// b.setAttribute('data-useragent',  navigator.userAgent);
6// b.setAttribute('data-platform', navigator.platform);
7
8// sample CSS: html[data-useragent*='Chrome/13.0'] { ... }
9
10
11// remap jQuery to $
12
13
14
15
16/* trigger when page is ready */
17
18(function ($) {
19
20	var windowResize;
21	var windowResizeSmaller;
22
23	function setCookie(cname, cvalue, exdays) {
24		const d = new Date();
25		d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
26		let expires = "expires="+d.toUTCString();
27		document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
28	}
29
30	function deleteCookie(cname) {
31			const d = new Date();
32			d.setTime(d.getTime() - (24 * 60 * 60 * 1000)); // Set expiration time to past date
33			let expires = "expires="+d.toUTCString();
34			document.cookie = cname + "=;" + expires + ";path=/";
35	}
36	function getCookie(name) {
37		const value = `; ${document.cookie}`;
38		const parts = value.split(`; ${name}=`);
39		if (parts.length === 2) {
40			return parts.pop().split(';').shift();
41		}
42		return null; // cookie not found
43	}
44
45
46	function scrollTo(scrollTarget) {
47		document.querySelector(scrollTarget).scrollIntoView({
48		behavior: 'smooth'
49		})
50	}
51	/* trigger when page is ready */
52$(document).ready(function (){
53	// var productView = kraneSite;
54	var svg_color = "";
55	var mobileNavActive = "closed";
56	var prevMobileThemeItem = "";
57	var selectedMobileTheme = "";
58	var selectedMobileProduct = "";
59	var prevMobileNavItem = "";
60	var breadcrumb = false;
61
62
63	var prevNavItem;
64	var prevThemeItem;
65	var selectedPlatformClass = "";
66	var selectedProduct = "";
67	var selectedTheme = "";
68	var breadcrumbTheme ="";
69
70			// kraneSite = kraneSite ? kraneSite : 'kraneshares';
71//make global so the theme click event has access
72
73
74	if(kraneSite === "kraneshares") {
75		$('.desktop-product-drop.site-theme.kfafunds, .desktop-product-drop.single-product.kfafunds, .desktop-product-drop.single-product.europe').addClass('hidden');
76		selectedPlatformClass = '.kraneshares';
77	}
78
79	if(kraneSite === "kfafunds") {
80		$('.desktop-product-drop.site-theme.kraneshares, .desktop-product-drop.single-product.kraneshares, .desktop-product-drop.single-product.europe').addClass('hidden');
81		selectedPlatformClass = '.kfafunds';
82
83	}
84	if(kraneSite === "europe") {
85		$('.desktop-product-drop.site-theme.kraneshares, .desktop-product-drop.single-product.kraneshares, .desktop-product-drop.site-theme.kfafunds, .desktop-product-drop.single-product.kfafunds').addClass('hidden');
86		selectedPlatformClass = '.ucits';
87
88	}
89
90
91
92// $('.mobile-product-drop .platform-item').click(function(e) {
93// 	$('.mobile-product-drop .site-theme').addClass('black-theme');
94// 	var currentPlatform = '<span class="platform-breadcrumb"><i class="fa fa-chevron-right"></i>' + $(this).data('label') + '</span>';
95// 			breadcrumb = true;
96// 	var currentTarget = $(e.currentTarget);
97// 			selectedMobileProduct = currentTarget.data('value');
98// 	$('#platform-insert').after(currentPlatform);
99// 	$('.mobile-product-drop .platform-item, .mobile-product-drop .platform-item-link, .mobile-product-drop .themes-container').addClass("hidden");
100// 	$('.mobile-product-drop .product-container').hide();
101// 	//hide all the products
102//
103// 	// insert current platform into top breadcrub bar
104// 	//hide everything except the current theme container
105//
106//
107//
108// 	$(this).next('.mobile-product-drop .themes-container').removeClass('hidden');
109// 	// if(breadcrumbTheme) {
110// 	// $('.mobile-product-drop .' + breadcrumbTheme)[0].click();
111// 	// }
112// // remove the hidden class from the matching theme container
113// })
114
115$('.mobile-product-drop .site-theme:not(.always-visible)').click(function(e) {
116	var currentTarget = $(e.currentTarget);
117			svg_color =  currentTarget.data('theme-color');
118			selectedMobileTheme = currentTarget.data('theme');
119			$('.mobile-product-drop .site-theme:not(.always-visible)').not(currentTarget).addClass('black-theme');
120			//Make all elements black
121			currentTarget.toggleClass('black-theme');
122
123			$('.mobile-product-drop .site-theme').removeClass('active-theme');
124			//remove the active theme indicator class from all elements
125			currentTarget.addClass('active-theme');
126			//Add it only to the current theme
127			$('.mobile-product-drop .site-theme:not(.active-theme)').next('.product-container').slideUp();
128			//close all the themes except one you just clicked
129			$(this).next('.product-container').slideToggle();
130			// Toggle the open or close of the one you just clicked
131
132})
133
134$('#products_a').click(function() {
135
136	// When you open the nav again check if the current slug is the data slug of any of the elements
137	var matchingTicker;
138	var currentCookie = localStorage.getItem('data-theme');
139	$('.desktop-product-drop .single-product').each(function(e) {
140		if (currentSlug === $(this).data('slug') && currentCookie === $(this).data('theme')) {
141			matchingTicker = $(this);
142			return false;
143		} else if (currentSlug === $(this).data('slug') && currentCookie !== $(this).data('theme')) {
144			matchingTicker = $(this);
145		}
146
147	})
148	//If a match was found
149	if(matchingTicker) {
150		matchingTicker.addClass('current-product').find('.product-ticker a')
151		matchingTicker.css("color", matchingTicker.data('theme-color'));
152		breadcrumbTheme = matchingTicker.data('theme');
153	}
154
155
156
157
158	if(!breadcrumb && $(this).hasClass('top_bar_clicked') && $(this).hasClass('mobile_hidden') && $(window).width() <= 980) {
159		//IF you are already in the menu and there is no breadcrumb
160		$('#products_drop').hide();
161		$('#products_a').removeClass('mobile_hidden');
162		$(this).removeClass('top_bar_clicked');
163		$('.mobile-product-drop').addClass("hidden");
164	}
165
166
167
168 // if(!selectedTheme){
169	// 	$('.desktop-product-drop .platform-item')[0].click();
170 //
171	// }
172
173});
174
175	$('.desktop-product-drop .platform-item').click(function(e) {
176		var currentTarget = $(e.currentTarget);
177
178			selectedProduct = currentTarget.data('value');
179
180
181
182		$('.desktop-product-drop .platform-item').removeClass('top_bar_clicked');
183		currentTarget.addClass('top_bar_clicked');
184			//kfa funds
185		var defaultSelected = false;
186
187		$('.desktop-product-drop .site-theme').map(function() {
188			if(!$(this).hasClass(selectedProduct) && !$(this).hasClass('always-visible')) {
189				$(this).addClass('hidden');
190			} else if(breadcrumbTheme) {
191				$(this).removeClass('hidden');
192				$('.desktop-product-drop .site-theme' + selectedPlatformClass + '.' + breadcrumbTheme).click();
193				defaultSelected = true;
194
195				breadcrumbTheme = '';
196			} else {
197				$(this).removeClass('hidden');
198					if(!defaultSelected) {
199						$('.desktop-product-drop .site-theme' + "." + selectedProduct)[0].click();
200					}
201					defaultSelected = true;
202
203			}
204		});
205
206
207		prevNavItem = currentTarget;
208
209	});
210
211
212
213	$('.desktop-product-drop .site-theme:not(.always-visible)').click(function(e) {
214		var currentTarget = $(e.currentTarget);
215				svg_color =  currentTarget.data('theme-color');
216				selectedTheme = currentTarget.data('theme');
217
218
219		$('.desktop-product-drop .platform-item').removeClass('active-theme');
220		currentTarget.addClass('active-theme');
221
222		$('.desktop-product-drop .site-theme').addClass('black-theme').css("border-bottom", "");
223		currentTarget.removeClass('black-theme').css("border-bottom", "3px solid " + svg_color);
224
225		$('.desktop-product-drop .single-product').map(function() {
226
227			if(!$(this).hasClass(selectedProduct) || !$(this).hasClass(selectedTheme)) {
228				$(this).addClass("hidden");
229			} else {
230				$(this).removeClass("hidden");
231			}
232		});
233		prevThemeItem = currentTarget;
234
235
236	});
237
238	//When you click on a product ticker or link, set cookie to that data theme.
239
240	$('.product-ticker a, .product-details a, .page-template-splash_landing_page .trending-fund a').click(function(e) {
241		e.preventDefault(); // stop default navigation for now
242	var dataTheme = $(this).data('theme');
243	localStorage.setItem("data-theme", dataTheme);
244
245	var date = new Date();
246	date.setTime(date.getTime() + (10 * 1000));
247	var expires = "; expires=" + date.toGMTString();
248	document.cookie = 'data-theme=' + dataTheme + expires + ";path=/";
249	// force navigation after cookie is set
250	window.open($(this).attr('href'), '_blank')
251});
252
253
254	$('.product-papers a, .product-ticker, .product-details a').hover(function(e) {
255		var currentTarget = $(e.currentTarget);
256		$(this).closest('.single-product').css({
257			background: "#f4f6f7",
258			transition: "all .35s ease"
259		});
260		$(this).closest('.single-product').find('.product-ticker a').css({
261			color: svg_color,
262			transition: "all .35s ease"
263		});
264	});
265
266$('.single-product').mouseleave(function(e) {
267	$(this).css("background", "");
268	$(this).find('.product-ticker a').css("color", "" );
269
270
271})
272
273//Set mailing list drop down
274var onReportPage = document.location.href.indexOf("/reports/") > -1;
275var onWebinarPage = document.location.href.indexOf("/webinars/") > -1;
276var onLiveEventPage = document.location.href.indexOf("/live-events/") > -1;
277var onSuitePage = document.location.href.indexOf("-suite") > -1;
278var onPrivateSuitePage = window.location.pathname === '/private-funds/';
279
280if (!onReportPage && !onWebinarPage && !onLiveEventPage && !onSuitePage && !onPrivateSuitePage && getCookie('the_cookie') !== 'true' && localStorage.getItem('footer-pop')){
281		chimpCall();
282	}
283
284
285function chimpCall() {
286	setTimeout(function() {
287
288		setTimeout(function() {
289			scrollTo('.header')
290		}, 100);
291		setTimeout(function() {
292			$('a#mailing_list_a').trigger("click");
293	}, 1000);
294		}, 5000);
295		setCookie('the_cookie', 'true', { expires: 30, path: '/' });
296
297}
298
299//Set Subscribe Prompt Stopper Cookies
300
301$('#mc-embedded-subscribe').click(function(){
302	setCookie('the_cookie', 'true', { expires: 365, path: '/' });
303});
304
305if(typeof currentSlug == 'undefined' && (kraneSite === "chinalastnight" || kraneSite === 'climatemarketnow')) {
306	 currentSlug = null;
307}
308if( (kraneSite === 'kraneshares' || kraneSite === 'europe' || kraneSite === 'kfafunds' || kraneSite === "chinalastnight" || kraneSite === 'climatemarketnow') && typeof currentSlug !== 'undefined') {
309
310	let footerPopCookie = getCookie('footer-pop');
311	let fundClosurePopCookie = localStorage.getItem(currentSlug+'-closure-pop');
312	let urlParams = new URLSearchParams(window.location.search);
313	let fullURL = window.location.href;
314	let localStorageUrl;
315	let urlContainsIdParam = urlParams.has('mc_eid') || urlParams.has('mc_kfa_eid') || urlParams.has('suid');
316	let idInLocalStorage =  localStorage.getItem('referrer-url');
317			idInLocalStorage =   idInLocalStorage && ( idInLocalStorage.includes('mc_kfa_eid') || idInLocalStorage.includes('mc_eid') || idInLocalStorage.includes('suid') ) ? true : false;
318	//initialize storage for saved params so it is never undefined
319	const cookieTypeStates = { krane_fc: 'accept', krane_pc: 'accept' };
320
321// 	if (isExploreOrProductPage) {
322//
323//     // store referrer params if not already stored
324//     if (!localStorage.getItem('referrer-url') && urlParams.size > 0) {
325//         localStorage.setItem('referrer-url', urlParams);
326// 				console.log( "setting to ",urlParams);
327//     }
328//
329//     // set cookies normally set on accept
330//     if (!getCookie('footer-pop')) {
331//         setCookie('footer-pop', 'true', 365);
332//     }
333//
334//     if (!getCookie('krane_pc')) {
335//         setCookie('krane_pc', 'allow', 365);
336//     }
337//
338// }
339
340	if((onWebinarPage || onReportPage || onLiveEventPage) && urlContainsIdParam) {
341		$('[data-cookie-type="krane_fc"]').closest('.cookie-category').hide();
342		setCookie('krane_fc', 'accept', 365);
343	}
344
345	window.history.replaceState(null, '', window.location.pathname);
346	let bypassFooterPop = false;
347
348	if(urlParams.has('bypass') || fullURL.includes('/privacy-policy') || fullURL.includes('/whistleblower-policy') ) {
349		bypassFooterPop = true;
350	}
351
352	if(urlParams.has('bypass')) {
353		setCookie('footer-pop', 'true', 365);
354		localStorage.setItem('footer-pop', 'true');
355		// window.location.replace(fullURL);
356
357	}
358
359	if(!footerPopCookie && !bypassFooterPop) {
360		if(kraneSite === 'kraneshares' || kraneSite === 'kfafunds' || kraneSite === "chinalastnight" || kraneSite === 'climatemarketnow') {
361
362			if( urlContainsIdParam || idInLocalStorage ) {
363					$('.cookie_shadow_container').addClass('modal_shadow footer_pop_modal_shadow')
364																			 .fadeIn(200)
365																			 .addClass('up');
366					$('html, body').css({
367								overflow: 'auto',
368								height: '100%'
369						});
370					}
371		}
372			$( "#footer_pop_msg" ).removeClass('hidden');
373			if(!localStorage.getItem('referrer-url')) {
374				//if the url is not already saved then save it, otherwise use the saved one
375				localStorage.setItem('referrer-url', urlParams);
376				//save it as an object
377			 //hoist this data up out of conditional and save it - use it in the button redirect.
378			}
379			localStorageUrl = localStorage.getItem('referrer-url');
380
381			//do this on every site
382	}
383
384
385	if(!fundClosurePopCookie && footerPopCookie) {
386
387		$( ".fund_closure_announcement" ).removeClass('hidden');
388	}
389
390
391	$('a.accept_button').click(function(){
392		if ($(this).hasClass('fund_closure_announcement_btn')) {
393			$('#footer_pop_msg').fadeOut(0);
394			$('.fund_closure_announcement').fadeOut(500, function () {
395					$('#footer_pop_msg').fadeIn(500);
396			});
397			localStorage.setItem(currentSlug+'-closure-pop', 'true');
398
399		} else {
400			$('#footer_pop_msg, .footer_pop_modal_shadow').fadeOut(500);
401			setCookie('footer-pop', 'true', 365);
402			localStorage.setItem('footer-pop', 'true');
403			//always do the above on every site on click:
404			Object.entries(cookieTypeStates).forEach(([key, value]) => {
405				if(value === 'deny') {
406					setCookie(key,value,365);
407				}
408			});
409			if(kraneSite === 'kraneshares' || kraneSite === 'kfafunds' || kraneSite === "chinalastnight" || kraneSite === 'climatemarketnow') {
410
411				if(localStorageUrl && urlParams.size == 0) {
412				 separator = fullURL.includes('?') ? '&' : '?';
413				 fullURL+=(separator + localStorageUrl);
414			 }
415			 localStorage.removeItem('referrer-url');
416				window.location.replace(fullURL);
417			}
418		}
419
420
421	});
422
423
424
425	$('.cookie-preferences-button').data('action','preferences');
426	//all cookies accepted by default
427	$('.cookie-preferences-container').css('display', 'flex').hide();
428
429	$('.cookie-preferences-button').click(function(e) {
430
431		if($(this).data('action') === 'preferences') {
432
433
434			 if ($('.cookie-preferences-container').hasClass('active')) {
435					 $('.cookie-preferences-container').removeClass('active').slideUp(200);
436			 } else {
437					 $('.cookie-preferences-container').addClass('active').slideDown(200);
438			 }
439			$('.cookie-preferences-button').text('Save Preferences').data('action','save');
440		} else {
441			//delete cookies to remove possibility of error
442			deleteCookie('krane_ec');
443			deleteCookie('krane_fc');
444			deleteCookie('krane_pc');
445			//set cookies for preferences to pass to id redirect
446			Object.entries(cookieTypeStates).forEach(([key, value]) => {
447				if(value === 'deny') {
448					setCookie(key,value,365);
449				}
450			});
451			//click on the regular button and refresh page with params
452			$('a.accept_button').click();
453		}
454
455	})
456
457	$('.bi-check-container .option:not(.disabled)').click(function(e) {
458		acceptanceStatus = $(this).data('acceptance') || null;
459		cookieCatName = $(this).parent().data('cookie-type') || null;
460		currentToggle = $(this).parent();
461		currentToggle.find('.active-option').not($(this)).removeClass('active-option');
462		$(this).addClass('active-option');
463		if (cookieCatName && cookieTypeStates.hasOwnProperty(cookieCatName)) {
464		cookieTypeStates[cookieCatName] = acceptanceStatus;
465
466	}
467	})
468	if(footerPopCookieCheck && !getCookie('chimp_cookie') ){
469		if(urlParams.has('mc_eid')) {
470			const mcValue = urlParams.get('mc_eid');
471			setCookie('chimp_cookie', mcValue, 365);
472			window.location.replace(window.location.pathname)
473		}
474		else if(urlParams.has('mc_kfa_eid')) {
475			const kfaValue = urlParams.get('mc_kfa_eid');
476			setCookie('chimp_cookie', kfaValue, 365);
477			setCookie('mc_user_table_type', 'kfa', 365);
478			window.location.replace(window.location.pathname)
479		}
480		else if(urlParams.has('suid')) {
481			const suidValue = urlParams.get('suid');
482			setCookie('chimp_cookie', suidValue, 365);
483			setCookie('mc_user_table_type', 'suid', 365);
484			window.location.replace(window.location.pathname)
485		}
486	}
487
488}
489
490
491	var thumbnailBaseUrl = templateUrl ? templateUrl + "/images/" : "https://kraneshares.com/wp-content/themes/2020_11_13_krane_platform/images/";
492	var imgFile;
493		if(kraneSite === "chinalastnight") {
494			imgFile =  typeof altPosterToggle !== 'undefined' ? "cln_video_poster.jpeg" : "cln-thumbnail.png";
495	} else if(kraneSite === "kfafunds") {
496			imgFile = "kfa-thumbnail.png";
497	} else if(kraneSite === "climatemarketnow") {
498			imgFile = "cmn.png";
499	}	else {
500			imgFile = "kraneshares-thumbnail.png";
501	}
502
503	$('.wp-block-video video, .cln-video').map(function() {
504		var videoAttr = $(this).attr("poster");
505
506		if(typeof altPosterToggle !== 'undefined') {
507			$(this).attr({
508				"poster": thumbnailBaseUrl + imgFile,
509				"preload": "auto",
510			});
511		} else if(!videoAttr) {
512			$(this).attr({
513				"poster": thumbnailBaseUrl + imgFile,
514				"preload": "auto",
515			});
516		}
517	});
518
519
520
521var getUrlParameter = function getUrlParameter(sParam) {
522	var sPageURL = decodeURIComponent(window.location.search.substring(1)),
523			sURLVariables = sPageURL.split('&'),
524			sParameterName,
525			i;
526
527	for (i = 0; i < sURLVariables.length; i++) {
528			sParameterName = sURLVariables[i].split('=');
529
530			if (sParameterName[0] === sParam) {
531					return sParameterName[1] === undefined ? true : sParameterName[1];
532			}
533	}
534};
535
536var success = getUrlParameter('success');
537var error = getUrlParameter('error');
538var confirm = getUrlParameter('confirm');
539var event_rsvp = getUrlParameter('event-rsvp');
540var city_select = getUrlParameter('city');
541
542
543	// if (success === "true")  {
544	// 	$.scrollTo( '#obor_signup', 600, { easing:'swing' });
545	// }
546	//
547	// if (error === "true")  {
548	// 	$.scrollTo( '#obor_signup', 600, { easing:'swing' });
549	// }
550	//
551	// if (confirm === "true")  {
552	// 	$.scrollTo( '#obor_signup', 600, { easing:'swing' });
553	// }
554	//
555	// if (event_rsvp === "true")  {
556	//
557	// 	$.scrollTo( '#obor_signup', 600, { easing:'swing' });
558	// }
559	//
560	// if (city_select != null)  {
561	//
562	// 	$.scrollTo( '#signup', 600, { easing:'swing' });
563	//
564	// }
565
566
567
568$('#webinar_signup').submit(function(){
569			if ($('input#left_field').val().length != 0) {
570					return false;
571			}
572});
573
574	$('.obor_frame').css({
575		'height': $('.obor_main_feature').height()
576	});
577
578
579
580
581	$('.popup').click(function() {
582	 var NWin = window.open($(this).prop('href'), '', 'scrollbars=1,height=400,width=400');
583	 if (window.focus)
584	 {
585		 NWin.focus();
586	 }
587	 return false;
588	});
589
590
591
592
593
594$("a#subscribe_link").click(function(e){
595$('a#mailing_list_a').trigger("click");
596e.preventDefault();
597});
598
599$( ".current-cat a" ).prepend( "<i class='fa fa-arrow-right'></i>&nbsp;" );
600$(".current-menu-item a").prepend( "<i class='fa fa-arrow-right'></i>&nbsp;" );
601$(".current_sub_nav").prepend( "<i class='fa fa-arrow-right'></i>&nbsp;" );
602
603	$('.nav_section_container').hide();
604
605	var open = $('.top_bar_a'),
606			a = $('.main_navigation').find('.top_bar_a');
607
608
609			open.click(function(){
610
611					var $this = $(this),
612							speed = 500;
613
614					if(!$(this).hasClass('cln_switch') && !$(this).hasClass('cmn_switch') && !breadcrumb){
615
616					if($this.hasClass('top_bar_clicked') === true) {
617					$this.removeClass('top_bar_clicked');
618					dropdown = ($this.parent().index());
619
620					if (document.documentElement.clientWidth < 980) {
621					$('.nav_section_container').eq(dropdown).hide();
622					$('.mobile_nav_collapse').slideUp(speed);
623					$('a.nav_section_label').removeClass('sub_nav_clicked');
624					}
625					else {
626					$('.nav_section_container').eq(dropdown).slideUp(speed);
627					}
628					}
629
630				else if(a.hasClass('top_bar_clicked') === false) {
631
632							$this.addClass('top_bar_clicked');
633					dropdown = ($this.parent().index());
634					$('.nav_section_container').eq(dropdown).slideDown(speed);
635					}
636
637				else {
638
639							a.removeClass('top_bar_clicked');
640					$('.nav_section_container').slideUp(speed);
641							$this.addClass('top_bar_clicked');
642					dropdown = ($this.parent().index());
643					$('.nav_section_container').eq(dropdown).delay(speed).slideDown(speed);
644
645					}
646
647				$('a.top_bar_a').not(this).toggleClass('mobile_hidden');
648			} else if(breadcrumb) {
649						//If you clicked and there is already a breadcrumb, remove it and return to all platforms
650							$('.platform-breadcrumb').remove();
651							breadcrumb = false;
652							$('.mobile-product-drop .themes-container').addClass('hidden');
653							$('.mobile-product-drop .platform-item, .mobile-product-drop .platform-item-link').removeClass('hidden');
654							//If there is already a breadcrumb, remove it.
655						}
656
657			});
658
659			if(getCookie('contact-drop')) {
660				$('.top_bar_a#contact_us_a').click();
661				deleteCookie('contact-drop');
662			}
663
664			$('.obor_learn_more, .kba_select_city').click(function(){
665				// $.scrollTo( '#obor_signup', 600, { easing:'swing' });
666				scrollTo('#obor_signup');
667			});
668
669
670
671$('a.top_bar_a').not(this).toggleClass('mobile_hidden');
672
673
674
675
676$('.up_icon').click(function(){
677 $('.main_navigation').find('.top_bar_a').removeClass('top_bar_clicked');
678 $('.menu-link').removeClass('clicked');
679$('.nav_section_container').slideUp(500);
680$('a.top_bar_a').not(this).toggleClass('mobile_hidden');
681scrollTo('body');
682if (document.documentElement.clientWidth < 980) {
683
684		$('ul.main_navigation').slideUp(500);
685}
686
687
688}
689);
690$('.nav_section_label').click(function(){
691
692	 b = $('.main_drop_downs').find('.nav_section_label');
693
694	if (document.documentElement.clientWidth < 980) {
695
696
697		if($(this).hasClass('sub_nav_clicked') === true) {
698				$(this).removeClass('sub_nav_clicked');
699				$('.mobile_nav_collapse').slideUp(500);
700
701		}
702
703		else if(b.hasClass('sub_nav_clicked') === false){
704		$(this).addClass('sub_nav_clicked');
705		$(this).next('.mobile_nav_collapse').slideDown(500);
706
707		}
708
709
710		else {
711				b.removeClass('sub_nav_clicked');
712				$('.mobile_nav_collapse').slideUp(500);
713				$(this).addClass('sub_nav_clicked');
714				$(this).next('.mobile_nav_collapse').slideDown(500);
715		}
716
717}
718});
719
720$('.menu-link').click(function(){
721	// CC 8.25 mobile nav active conditional added
722	$('.platform-breadcrumb').remove();
723	breadcrumb = false;
724	$('ul.main_navigation').slideToggle(500);
725	$('.nav_section_container').slideUp(500);
726	$('.mobile_nav_collapse').slideUp(500);
727	$('a.top_bar_a').removeClass('mobile_hidden top_bar_clicked');
728	$('a.nav_section_label').removeClass('sub_nav_clicked');
729});
730
731
732//Front page fund map
733
734$('.related_content_home').click(function() {
735
736var $this = $(this);
737
738
739if($this.hasClass('home_clicked') === true) {
740
741$this.removeClass('home_clicked');
742$this.children('.inner_hp_nav').slideUp(500);
743}
744
745else if($this.hasClass('home_clicked') === false) {
746
747
748$('li').removeClass('home_clicked');
749$this.addClass('home_clicked');
750$('.inner_hp_nav').slideUp(500);
751$this.children('.inner_hp_nav').slideDown(500);
752
753
754}
755
756else {
757
758}
759
760
761});
762
763// CC Arrow toggle click below
764
765$('.fund-documents-section .kiid_holder').hide();
766
767$('li.kiid_toggle').click(function(e){
768		e.preventDefault();
769		var $this = $(this);
770		var currentTarget = $(e.currentTarget);
771// current target targets the specific element you are clicking on (should be A tag), and finds the children to add the arrow
772	if(currentTarget.hasClass('product_sidebar_clicked') === true) 	{
773
774	currentTarget.removeClass('product_sidebar_clicked');
775
776	currentTarget.next('ul').slideUp(300);
777
778
779	$(e.currentTarget.lastElementChild.children).toggleClass('fa-arrow-down fa-arrow-right');
780
781} else if(currentTarget.hasClass('product_sidebar_clicked') === false) {
782
783		currentTarget.removeClass('product_sidebar_clicked');
784		currentTarget.addClass('product_sidebar_clicked');
785
786			if(currentTarget.hasClass('product-page-dropdown')) {
787			currentTarget.next('ul').slideDown({
788							start: function () {
789								$(this).css({
790									"display": "flex",
791									"flex-flow": "row wrap",
792									"justify-content": "space-between",
793								})
794							}, duration: 300
795						});
796			} else {
797				currentTarget.next('ul').slideDown(400)
798			}
799			$(e.currentTarget.lastElementChild.children).toggleClass('fa-arrow-right fa-arrow-down');
800		}
801});
802
803$('.usa_switch').attr('href', function() {
804
805return this.href + 'usa';
806
807});
808
809$('.ucits_switch').attr('href', function() {
810return this.href + 'ucits';
811});
812
813$('.kfa_switch').attr('href', function() {
814return this.href + 'kfa';
815});
816
817$('.cln_switch').attr('href', function() {
818return this.href + 'cln';
819});
820
821$('.cmn_switch').attr('href', function() {
822return this.href + 'cmn';
823});
824
825$('.ivoletf_switch').attr('href', function() {
826return this.href + 'ivol';
827});
828
829$('.models_switch').attr('href', function() {
830return this.href + 'modelportfolios';
831});
832
833$('.institutional_switch').attr('href', function() {
834return this.href + 'institutional';
835});
836
837
838$('.custom_switch').attr('href', function() {
839return this.href + 'cm';
840});
841
842$('.mutual_fund_switch').attr('href', function() {
843return this.href + 'mf';
844});
845
846var hash = null;
847var custom_url;
848
849if (window.location.href.indexOf("#") > -1){
850hash = location.hash.substr(1);
851}
852
853$(window).on('hashchange', function() {
854hash = location.hash.substr(1);
855});
856
857$('.custom_switch, .custom_cmn_switch').click(function(e) {
858custom_url = $(this).data('url');
859})
860
861var checkCookie = getCookie('chimp_cookie');
862var checkCookieType = getCookie('mc_user_table_type');
863var exitLinkAppend = "";
864var exitLinkSeperator = "/?";
865
866if(checkCookie == null || checkCookie == 'undefined'){
867	exitLinkAppend = "";
868} else if(checkCookie !== null){
869	if(checkCookieType == null) {
870		exitLinkAppend = exitLinkSeperator+"mc_eid="+checkCookie;
871	} else if(checkCookieType == "kfa") {
872			exitLinkAppend = exitLinkSeperator+"mc_kfa_eid="+checkCookie;
873	} else if(checkCookieType == "suid") {
874			exitLinkAppend = exitLinkSeperator+"suid="+checkCookie;
875	}
876	else {
877	exitLinkAppend = "";
878}
879}
880	else {
881	exitLinkAppend = "";
882}
883
884
885var staging_environment = "false";
886var dev_environment = "false";
887var krane_site_base_link_usa = "kraneshares.com";
888var krane_site_base_link_eu = "kraneshares.eu";
889var krane_site_base_link_kfa = "kfafunds.com";
890var krane_site_base_link_br = "kraneshares.br";
891var krane_site_base_link_cln = "chinalastnight.com";
892var krane_site_base_link_cmn = "climatemarketnow.com";
893var krane_site_base_link_model_portfolios = "portfolios.kraneshares.com";
894
895if (window.location.href.indexOf("kranesharesnet") > -1){
896	staging_environment = "true";
897} else if (window.location.href.indexOf("kanedev") > -1){
898	dev_environment = "true";
899}
900
901if (staging_environment === "true")  {
902	krane_site_base_link_usa = "kranesharesnet.wpengine.com";
903	krane_site_base_link_eu = "kraneshareseu.kranesharesnet.wpengine.com";
904	krane_site_base_link_kfa = "kfafunds.kranesharesnet.wpengine.com";
905	krane_site_base_link_br = "brazil.kranesharesnet.wpengine.com";
906	krane_site_base_link_cln = "chinalastnight.kranesharesnet.wpengine.com";
907	krane_site_base_link_cmn = "climatemarketnow.kranesharesnet.wpengine.com";
908	krane_site_base_link_model_portfolios = "portfolios.kranesharesnet.wpengine.com";
909} else if(dev_environment === "true"){
910	krane_site_base_link_usa = "kanedev.wpengine.com";
911	krane_site_base_link_eu = "kraneshareseu.kanedev.wpengine.com";
912	krane_site_base_link_kfa = "kfafunds.kanedev.wpengine.com";
913	krane_site_base_link_br = "brazil.kanedev.wpengine.com";
914	krane_site_base_link_cln = "chinalastnight.kanedev.wpengine.com";
915	krane_site_base_link_cmn = "climatemarketnow.kanedev.wpengine.com";
916	krane_site_base_link_model_portfolios = "portfolios.kanedev.wpengine.com";
917}
918
919$('.exit_link').click(function(e) {
920
921e.preventDefault();
922if (hash === "usa") {
923	if(custom_url) {
924		window.location.href = "https://"+krane_site_base_link_usa + custom_url+exitLinkAppend
925	} else {
926		window.location.href = "https://"+krane_site_base_link_usa+exitLinkAppend;
927	}
928} else if (hash === "ucits") {
929	window.location.href = "https://"+krane_site_base_link_eu+exitLinkAppend;
930} else if (hash === "cln") {
931	window.location.href = "https://"+krane_site_base_link_cln+exitLinkAppend;
932} else if (hash === "cmn") {
933	window.location.href = "https://"+krane_site_base_link_cmn+exitLinkAppend;
934} else if (hash === "kfa") {
935	window.location.href = "https://"+krane_site_base_link_kfa+exitLinkAppend;
936} else if (hash === "ivol") {
937	window.location.href = "https://www.ivoletf.com/";
938} else if (hash === "modelportfolios") {
939	window.location.href = "https://"+krane_site_base_link_model_portfolios+exitLinkAppend;
940} else if (hash === "institutional") {
941	window.location.href = "https://"+krane_site_base_link_usa+"/institutional/"+exitLinkAppend;
942} else if (hash === "mf") {
943	window.location.href = "https://"+krane_site_base_link_usa+'/mutual-funds/krane-ubs-china-a-share-fund'+exitLinkAppend;
944} else if (hash === "cm") {
945	// let custom_url = $('.custom_switch').data('url');
946	if ((exitLinkAppend.indexOf('/?') != -1) && (custom_url.indexOf('engage.') != -1)) {
947
948		if(checkCookie == null || checkCookie == 'undefined'){
949				exitLinkAppend = "";
950			} else if(checkCookie !== null){
951				if(checkCookieType == null) {
952					exitLinkAppend = "&mc_eid="+checkCookie;
953				} else if(checkCookieType == "kfa") {
954						exitLinkAppend = "&mc_kfa_eid="+checkCookie;
955				} else if(checkCookieType == "suid") {
956						exitLinkAppend = "&suid="+checkCookie;
957				}
958				else {
959				exitLinkAppend = "";
960			}
961			}
962				else {
963				exitLinkAppend = "";
964			}
965
966	}
967
968	window.location.href = custom_url.toLowerCase().includes('https://') ? custom_url+exitLinkAppend : "https://"+custom_url+exitLinkAppend;
969
970	//check if has https before adding it
971}
972});
973
974$('.eu_exit_link').click(function(e) {
975if (hash === "usa") {
976	window.location.href = "https://"+krane_site_base_link_usa+exitLinkAppend;
977} else if (hash === "ucits") {
978	window.location.href = "https://"+krane_site_base_link_eu+exitLinkAppend;
979} else if (hash === "cln") {
980	window.location.href = "https://"+krane_site_base_link_cln+exitLinkAppend;
981} else if (hash === "cmn") {
982	window.location.href = "https://"+krane_site_base_link_cmn+exitLinkAppend;
983} else if (hash === "kfa") {
984	window.location.href = "https://"+krane_site_base_link_kfa+exitLinkAppend;
985} else if (hash === "modelportfolios") {
986	window.location.href = "https://"+krane_site_base_link_model_portfolios+exitLinkAppend;
987} else if (hash === "institutional") {
988	window.location.href = "https://"+krane_site_base_link_usa+"/institutional/"+exitLinkAppend;
989} else if (hash === "mf") {
990	window.location.href = "https://"+krane_site_base_link_usa+'/mutual-funds/krane-ubs-china-a-share-fund'+exitLinkAppend;
991}
992});
993
994
995$('.region_switch').click(function(){
996
997$('.modal_shadow').fadeIn(200);
998$('.modal_site_switch').slideDown(400);
999
1000});
1001
1002$('.buy-button, .how_to_buy_link').click(function(){
1003
1004$('.modal_shadow').fadeIn(200);
1005$('.modal_how_to_buy').slideDown(400);
1006
1007});
1008
1009$('.suite-product-buttons .buy-button').click(function() {
1010currentProduct = $(this).data('fund');
1011$('.modal_how_to_buy h1').text(`Invest in ${currentProduct.toUpperCase()} Through Your Broker`);
1012	$('.broker_logo').each(function() {
1013		let buyLink = new URL($(this).attr('href')); // 'this' refers to the current DOM element being iterated over
1014		buyLink.searchParams.set('product', currentProduct);
1015		$(this).attr('href', buyLink)
1016});
1017})
1018
1019
1020if($('.modal_pop_msg').hasClass('modal_eu_redirect')) {
1021$('.modal_shadow').fadeIn(200);
1022$('.modal_eu_redirect').slideDown(400);
1023}
1024
1025if($('.eu-new-visitor-pop').hasClass('up')) {
1026$('.europe-modal-shadow').fadeIn(200);
1027}
1028
1029$('.close_modal').click(function(e){
1030e.preventDefault();
1031$('.modal_shadow').fadeOut(600);
1032$('.modal_pop_msg').slideUp(200);
1033});
1034
1035var investorType = "individual";
1036var selectedCountryCode = $('.dropdown-selection').data('code');
1037var selectedCountryImg;
1038
1039$('.dropdown-selection').click(function(e) {
1040$('.dropdown').slideToggle(300, "swing");
1041$('.dropdown-selection .fa').toggleClass('dropdown-rotate');
1042})
1043
1044$('.dropdown-item').click(function(e) {
1045var selectedCountry = $(e.currentTarget).find('span').text();
1046		selectedCountryImg = $(this).find('img').attr('src');
1047		selectedCountryCode = $(e.currentTarget).data('code');
1048
1049$('.dropdown-selection').data('code', selectedCountryCode);
1050$('.dropdown-selection span').text(selectedCountry)
1051$('.dropdown-selection img').attr('src', selectedCountryImg);
1052$('.dropdown').slideToggle(300);
1053$('.dropdown-selection .fa').toggleClass('dropdown-rotate');
1054
1055})
1056
1057$('.investor-type').click(function(e) {
1058$('.investor-type').removeClass('selected-investor-type');
1059$(this).addClass('selected-investor-type');
1060investorType = $(this).data('it');
1061})
1062
1063
1064$('.eu-new-visitor-pop button').click(function(e) {
1065setCookie('it', investorType, 365);
1066setCookie('cc', selectedCountryCode, 365);
1067$('.europe-modal-shadow, .eu-new-visitor-pop').fadeOut(300);
1068$('.country_link .flag').attr('src', selectedCountryImg);
1069$(".investor-type[data-it='" + investorType +"']").addClass('selected-investor-type');
1070location.reload(true);
1071})
1072
1073$('.eu-edit-location button').click(function() {
1074setCookie('it', investorType, 365);
1075setCookie('cc', selectedCountryCode, 365);
1076$('.edit-location-modal-shadow, .eu-edit-location').fadeOut(300);
1077$('.country_link .flag').attr('src', selectedCountryImg);
1078location.reload(true);
1079})
1080
1081$('.country_link .flag').click(function() {
1082$('.eu-edit-location, .edit-location-modal-shadow').fadeIn(300);
1083$('.investor-type').addClass('.selected-investor-type')
1084});
1085// People Drop down
1086
1087$('.nav_section_sub_label').click(function() {
1088
1089var $this = $(this);
1090
1091if($this.hasClass('nav_section_sub_label_clicked') === true) {
1092
1093$this.removeClass('nav_section_sub_label_clicked');
1094$this.next('.sub_nav_collapse').slideUp(500);
1095}
1096
1097else if($this.hasClass('nav_section_sub_label_clicked') === false) {
1098
1099
1100$('a').removeClass('nav_section_sub_label_clicked');
1101$this.addClass('nav_section_sub_label_clicked');
1102$('.sub_nav_collapse').slideUp(500);
1103$this.next('.sub_nav_collapse').slideDown(500);
1104
1105}
1106
1107else {
1108
1109}
1110
1111
1112});
1113
1114
1115
1116// $('#scroller_fixed').localScroll({
1117//            target:'body'
1118//         });
1119//
1120//  $('#scroller').localScroll({
1121//            target:'body'
1122//         });
1123
1124
1125$('#scroller_fixed, #scroller').on('click', function(e) {
1126e.preventDefault();
1127scrollTo('body');
1128
1129})
1130
1131//Front page product map navigation
1132
1133
1134
1135
1136
1137//Product Page Show / Hide btns
1138
1139$('#premium_discount_section').hide();
1140
1141$('#distributions:not(.income, .income-h2)').hide();
1142$('.income .distribution-body').hide();
1143
1144$('.income .distribution-heading').click(function(e) {
1145currentTable = $(this).next('.distribution-body');
1146$('.distribution-body').not(currentTable).slideUp(500)
1147$('.income .distribution-heading').not(this).removeClass('open');
1148currentTable.slideToggle(500);
1149$(this).toggleClass('open');
1150$('.distribution-heading.open .fa').attr('class', 'fa fa-angle-up');
1151$('.distribution-heading .fa:not(.open .fa)').attr('class', 'fa fa-angle-down');
1152})
1153
1154$('.distributions-archive-heading').click(function(e) {
1155if($('.distributions-archive-heading .fa').hasClass('fa-plus')) {
1156	$(this).html('<i class="fa fa-minus"></i> View Fewer');
1157	$('.distributions-archive').slideDown(500);
1158} else {
1159	$(this).html('<i class="fa fa-plus"></i> View More');
1160	$('.distributions-archive').slideUp(500);
1161}
1162
1163})
1164
1165$('.premium_btn').click(function(e){
1166$('#premium_discount_section').removeClass('hidden');
1167$('#performance, #daily_performance' ).slideUp(500);
1168$('#performance, #daily_performance').addClass('hidden');
1169 $('#premium_discount_section').slideDown(500);
1170
1171e.preventDefault();
1172
1173});
1174
1175$('.premium_back_btn').click(function(e){
1176
1177$('#premium_discount_section').slideUp(500);
1178$('#premium_discount_section').addClass('hidden');
1179$('#performance, #daily_performance').removeClass('hidden');
1180$('#performance, #daily_performance').slideDown(500);
1181
1182e.preventDefault();
1183
1184});
1185
1186$('#distributions_btn').click(function(e){
1187$('#product_performance').slideUp(500);
1188$('#product_performance').addClass('hidden');
1189$('#distributions').removeClass('hidden');
1190$('#distributions').slideDown(500);
1191
1192e.preventDefault();
1193});
1194
1195$('#back_performance_btn').click(function(e){
1196$('#distributions').slideUp(500);
1197$('#distributions').addClass('hidden');
1198$('#product_performance').removeClass('hidden');
1199 $('#product_performance').slideDown(500);
1200
1201 e.preventDefault();
1202});
1203
1204
1205if(typeof hasIncomeHash !== 'undefined' && hasIncomeHash) {
1206	$('#distributions_btn').click();
1207}
1208
1209	 // $('.subscription-email-change span').click(() => {
1210		//  deleteCookie('mc_user_table_type');
1211		//  deleteCookie('chimp_cookie');
1212		//  //remove cookies except for footer pop
1213		//  //set them up as logged out
1214		//  window.location.replace( window.location.href + '?logout=true');
1215	 // })
1216	 //
1217	 // let loggedOutCheck = new URLSearchParams(window.location.search);
1218	 // if(loggedOutCheck.has('logout')) {
1219		//  //user just logged out
1220		//  window.history.replaceState(null, '', window.location.pathname);
1221		//  $(".distribution-alert.product-button").click();
1222		//  //open the pop up again when page $lowercase_distribution_frequency
1223	 //
1224		//  //remove that param
1225	 //
1226	 // }
1227
1228	 let subscriptionStatus;
1229	 let subStatusHeading;
1230	 let newSubStatus;
1231	 let faviconClass;
1232	 let formData;
1233
1234	 $('.subscription-email-change strong').click(() => {
1235		  deleteCookie('mc_user_table_type');
1236		  deleteCookie('chimp_cookie');
1237			if(onWebinarPage || onLiveEventPage || onReportPage) {
1238				location.reload();
1239		 }
1240
1241	 })
1242
1243
1244
1245	 $("#distributions-signup-form").submit(function(e) {
1246		 e.preventDefault();
1247		 let isValid = true;
1248		$(".required").each(function () {
1249				if ($(this).prop("required") && $(this).val() === "") {
1250						isValid = false;
1251						return false; // Exit the loop early if any required fields are empty
1252				}
1253		});
1254		if (!isValid) {
1255					return;
1256		}
1257		subscriptionStatus = $('#distributions-signup-form-submit').val().toLowerCase().trim();
1258
1259				if(!formData) {
1260					formData = $("#distributions-signup-form").serializeArray();
1261					//keep this in global scope for use later if they hit unsubscribe. Only redefine if empty
1262				}
1263
1264						let found = false;
1265						for (let i = 0; i < formData.length; i++) {
1266								if (formData[i].name === 'subscription_update') {
1267										formData[i].value = subscriptionStatus;
1268										found = true;
1269										break;
1270								}
1271						}
1272
1273						if (!found) {
1274								formData.push({'name': 'subscription_update', 'value': subscriptionStatus});
1275						}
1276						//the code above makes or edits the subscription status to match the one it is being changed to.
1277
1278			 $.ajax({
1279					 type: "POST",
1280					 url: `https://www.api.${krane_site_base_link_usa}/subscribe`,
1281					 crossDomain: true,
1282					 data: formData,
1283					 beforeSend: function (request) {
1284							request.withCredentials = false;
1285					},
1286					 headers:{
1287							 'X-Api-Key':'PU-CLltoX5u?eAl/6xXf',
1288					 },
1289					 success: function (response) {
1290						 if(response.success || (!response.success && response.message === 'no change')) {
1291
1292							 if(response){
1293
1294								 //give the fields in the form their new value from DB
1295								 //add disabled to them
1296								 if(subscriptionStatus === 'unsubscribe') {
1297									 //they just successfully unsubscribed
1298										subStatusHeading = "Subscribe to receive distributions updates."
1299										subStatusButton = "Receive Distribution Alerts";
1300										newSubStatus = 'Subscribe';
1301										faviconClass = "fas fa-envelope";
1302									 $('#distributions-signup-form .input-group').show();
1303									 $('#distributions-signup-form input').prop('readonly', false);
1304								 } else if(subscriptionStatus === 'subscribe') {
1305// if the are here they have already subscribed and are undoing it use prior stored info.
1306										subStatusHeading = "Unsubscribe from Distribution Alerts.";
1307										subStatusButton = "Unsubscribe from Distribution Alerts";
1308										newSubStatus = 'Unsubscribe';
1309										faviconClass = "fas fa-times-circle";
1310										$('#distributions-signup-form .input-group').hide();
1311										$('#distributions-signup-form .mc-field-group input').prop('readonly', true);
1312								 }
1313								 $('.distributions-modal .close_modal').click();
1314								 $('.distribution-alert').contents().last().replaceWith(subStatusButton);
1315								 $('#mc_embed_signup_h2').text(subStatusHeading);
1316								 $('#distributions-signup-form-submit').val(newSubStatus);
1317								 $('#distribution-email-icon').attr('class', faviconClass);
1318
1319							 } else {
1320								 // show message to user here
1321							 }
1322							 // add cookies here:
1323								//  if(response.message.adsource ) {
1324								// 	 setCookie('adsource', response.message.adsource, 365);
1325								//  }
1326								 if(response.message.id_type) {
1327									 setCookie('mc_user_table_type', response.message.id_type, 365);
1328								 }
1329								 if(response.message.krane_mailchimp_id) {
1330									 setCookie('chimp_cookie', response.message.krane_mailchimp_id, 365);
1331								 }
1332						 } else if(response.message === 'user database error') {
1333						 } else {
1334						 }
1335					 },
1336					 error: function (xhr, status, error) {
1337					 }
1338			 });
1339	 });
1340
1341	 $(".distribution-alert.product-button").click(function(e) {
1342		e.preventDefault();
1343		if(!formData) {
1344			//if they have already filled out form on this page load
1345			$('.distributions-modal, .distributions-modal-shadow').fadeIn(300);
1346		} else {
1347			$("#distributions-signup-form").submit();
1348		}
1349	 })
1350
1351
1352}); // End Document Ready
1353
1354
1355$(window).on('load', function() {
1356
1357
1358$('.menu-link').click(function(){
1359		$(this).toggleClass('clicked');
1360});
1361
1362
1363
1364
1365
1366});
1367
1368
1369var width = $(window).width(),
1370		height = $(window).height(),
1371		resizedLarger = false,
1372		resizedSmaller = false;
1373
1374
1375
1376
1377	// CC 9.3.21 window resize function to restore initial state
1378	$(window).resize(function() { //Window Resize -----------------------------------------------------------------
1379
1380
1381		if($(window).width() >= 980 && width <= 980 && !resizedLarger) {
1382			//if the screen size is over 980 and the mobile menu is activated
1383			$('.main_navigation').show();
1384
1385			$('.top_bar_clicked').click();
1386			resizedLarger = true;
1387			resizedSmaller = false;
1388			width = $(window).width();
1389		}
1390
1391		if($(window).width() <= 980 && width >= 980 && !resizedSmaller) {
1392			//if it was originally larger but you made it smaller
1393			// $('.up_icon').click()
1394			$('.main_navigation').find('.top_bar_a').removeClass('top_bar_clicked');
1395			$('.menu-link').removeClass('clicked');
1396		 $('.nav_section_container').slideUp(500);
1397		 $('a.top_bar_a').removeClass('mobile_hidden');
1398			$('.main_navigation').hide();
1399			resizedSmaller = true;
1400			resizedLarger = false;
1401			width = $(window).width();
1402
1403		}
1404
1405	});
1406
1407
1408
1409
1410
1411
1412let downloadCounter = 0;
1413$('.download_btn').on('click', function(){
1414downloadCounter = downloadCounter + 1;
1415if (downloadCounter == 1){
1416	if($('.download_btn').hasClass('celero_btn') == false){
1417		$('.download_btn').before('<h2 class = "bottom_b center_txt" style = "color: #037737;">Thank you. Your download should begin momentarily.</h2>');
1418	}
1419}
1420});
1421
1422$('.extra-button-dropdown .more-dropdown').on('click', function(){
1423
1424if($(this).hasClass('more-clicked') == true) {
1425	$(this).removeClass('more-clicked');
1426	$('.extra-button-dropdown .extra-button-options').slideUp(400);
1427}
1428
1429else {
1430	$(this).addClass('more-clicked');
1431	$('.extra-button-dropdown .extra-button-options').slideDown(400);
1432}
1433
1434});
1435
1436$('.performance-button').on('click', function(){
1437
1438if($(this).siblings().hasClass('performance-clicked') == true) {
1439	$(this).siblings().removeClass('performance-clicked');
1440	$(this).addClass('performance-clicked');
1441
1442}
1443
1444else {
1445	$(this).addClass('performance-clicked');
1446
1447}
1448
1449if($('.more-dropdown').hasClass('more-clicked') == true) {
1450	$('.more-dropdown').removeClass('more-clicked');
1451	$('.extra-button-options').css('display','none');
1452
1453}
1454
1455if($('.extra-button-options .performance-button').hasClass('inactive')){
1456	$('.more-dropdown').html('More '+'<i class="fas fa-caret-down"></i>');
1457	$('.more-dropdown').removeClass('performance-clicked');
1458	$('.extra-button-options .performance-button').removeClass('inactive');
1459}
1460
1461});
1462
1463$('.extra-button-options .performance-button').on('click', function(){
1464
1465if($('.more-dropdown').is(":visible")) {
1466
1467	$clicked_button_text = $(this).text();
1468
1469	$('.more-dropdown').html($clicked_button_text+' '+'<i class="fas fa-caret-down"></i>');
1470	$('.more-dropdown').addClass('performance-clicked');
1471	$('.extra-button-options .performance-button').removeClass('inactive');
1472	$(this).addClass('inactive');
1473
1474}
1475
1476});
1477
1478
1479//Countdown Timer
1480
1481// Set the date we're counting down to
1482
1483if ($('#countdown-timer').length){
1484
1485let countDownDateEntered = $("#webinar-start-date").data("date");
1486let timezoneEntered = $("#webinar-start-date").data("tz");
1487
1488var countDownDate = new Date(countDownDateEntered+" "+timezoneEntered).getTime();
1489
1490// Update the count down every 1 second
1491var x = setInterval(function() {
1492
1493// Get today's date and time
1494var now = new Date().getTime();
1495
1496// Find the distance between now and the count down date
1497var distance = countDownDate - now;
1498
1499// Time calculations for days, hours, minutes and seconds
1500var days = Math.floor(distance / (1000 * 60 * 60 * 24));
1501var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
1502var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
1503var seconds = Math.floor((distance % (1000 * 60)) / 1000);
1504
1505if (distance > 0) {
1506
1507	// Display the result in the element with id="countdown-timer"
1508	if(days > 0) {
1509
1510			document.getElementById("countdown-timer").innerHTML = days + "d : " + hours + "h : "
1511		+ minutes + "m : " + seconds + "s";
1512
1513	} else if(hours > 0) {
1514
1515			document.getElementById("countdown-timer").innerHTML = hours + "h : "
1516		+ minutes + "m : " + seconds + "s";
1517
1518	} else if(minutes > 0) {
1519
1520			document.getElementById("countdown-timer").innerHTML = minutes + "m : " + seconds + "s";
1521
1522	} else {
1523
1524			document.getElementById("countdown-timer").innerHTML = seconds + "s";
1525
1526	}
1527
1528// If the count down is finished, write some text
1529} else if (distance < 0) {
1530	clearInterval(x);
1531	$('.faded-img-container').fadeOut();
1532}
1533
1534}, 1000);
1535
1536
1537}
1538
1539// CC 7.29.21 Mutual Fund Change
1540
1541$('.share_class_link').click(function(e){
1542
1543var currentWrapper = $(e.currentTarget.parentNode);
1544
1545
1546if(currentWrapper.hasClass('open')){
1547
1548currentWrapper.find('#product_share_class_list').slideUp(400);
1549currentWrapper.find('#share_class_button .kiid_arrow').toggleClass('fa-arrow-down fa-arrow-right');
1550currentWrapper.removeClass('open');
1551
1552} else {
1553
1554currentWrapper.find('#product_share_class_list').slideDown(400);
1555currentWrapper.find('#share_class_button .kiid_arrow').toggleClass('fa-arrow-down fa-arrow-right');
1556currentWrapper.addClass('open');
1557
1558}
1559
1560e.preventDefault();
1561
1562});
1563
1564$('.share_class_list_element').click(function(e){
1565	var shareListItem = $(e.currentTarget);
1566
1567let selectedListText = $(shareListItem).text();
1568
1569let selectedListTicker = $(shareListItem).data('ticker');
1570
1571let selectedListShareClass = $(shareListItem).data('shareclass');
1572let buttonText = $('#share_class_button').text();
1573let buttonTicker = $('#share_class_button').data('ticker');
1574let buttonShareClass = $('#share_class_button').data('shareclass');
1575
1576if ($('.share_class_wrapper').hasClass('open')) {
1577	$('.share_class_list').slideUp(200);
1578	$('.share_class_wrapper').removeClass('open');
1579}
1580
1581$('.share_class_link').html('<i class="kiid_arrow fa fa-arrow-right"></i> Share Class: '+selectedListShareClass+' ('+selectedListTicker+')');
1582$('.share_class_link').data('ticker',selectedListTicker);
1583$('.share_class_link').data('shareclass',selectedListShareClass);
1584$('.share_class_list_element').html(buttonShareClass+' ('+buttonTicker+')');
1585$('.share_class_list_element').data('ticker', buttonTicker);
1586$('.share_class_list_element').data('shareclass', buttonShareClass);
1587
1588
1589for (var i = FundClassData.length - 1; i >= 0; i--) {
1590
1591	if(FundClassData[i].ticker == selectedListTicker){
1592
1593		$('.mutual_fund_ticker').text(FundClassData[i].ticker);
1594		$('.mutual_fund_share_class').text(FundClassData[i].share_class);
1595		$('.mutual_fund_gross_expense').text(FundClassData[i].gross_expense);
1596		$('.mutual_fund_net_expense').text(FundClassData[i].net_expense);
1597		$('.mutual_fund_minimum').text(FundClassData[i].minimum);
1598
1599
1600		$('.mutual-fund-cell').map(function() {
1601			var cellDataVal = $(this).data('value');
1602			if(cellDataVal) {
1603				var newData = FundClassData[i][cellDataVal] && FundClassData[i][cellDataVal] != 0 ? FundClassData[i][cellDataVal] + '%' : '–' ;
1604				$(this).text(newData);
1605			}
1606
1607		})
1608
1609	}
1610
1611}
1612
1613
1614e.preventDefault();
1615
1616});
1617
1618// CC Mutual Fund Change End
1619
1620$(window).resize(function() { //Window Resize -----------------------------------------------------------------
1621
1622if($(window).width() > 590){
1623
1624	$('.extra-button-options').css('display','flex');
1625	$('.extra-button-options .performance-button').removeClass('inactive');
1626	$('.more-dropdown').html('More '+'<i class="fas fa-caret-down"></i>');
1627
1628} else {
1629
1630	$('.extra-button-options').css('display','none');
1631
1632}
1633});
1634
1635//Equal Heights -----------------------------------------------------------------
1636$.fn.equalHeightify = function() {
1637			var highest = 0; // keep track of the greatest height
1638			$(this).each(function() { // for each element
1639					if ($(this).height() > highest) { // compare heights
1640							highest = $(this).height();
1641					}
1642			});
1643			$(this).height(highest); // set new height
1644	}
1645
1646//End Equal Heights -----------------------------------------------------------------
1647
1648
1649$('.header_view').bind('inview', function(event, isInView) {
1650 if (isInView) {
1651	// element is now visible in the viewport
1652	 $("#scroller_fixed").fadeOut(500);
1653$(".kba_select_city").fadeIn(500);
1654
1655	} else {
1656
1657		$("#scroller_fixed").removeClass('hidden');
1658	$("#scroller_fixed").fadeIn(500);
1659	$(".kba_select_city").fadeOut(500);
1660	}
1661
1662
1663	$('.overlay-button').click(function(e) {
1664		var dataSlide = $(this).data('slide');
1665		$('.theme-slider-container .fas[data-slide-control=' + dataSlide + ']').click();
1666	})
1667
1668$('.menu-link').click(function(e){
1669
1670	if($(this).hasClass('clicked')){
1671
1672	resetMobileHeader();
1673	$(this).removeClass('clicked');
1674
1675	} else {
1676
1677	$('.header-left-wrapper').slideDown(400);
1678	$(this).addClass('clicked');
1679
1680	}
1681
1682});
1683
1684	function resetMobileHeader() {
1685		$('.header-left-wrapper').slideUp(400);
1686		$('.nav_section_container').slideUp(400);
1687		$('.nav-tab-element').css('display','flex');
1688		$('.nav-tab-element').removeClass('clicked');
1689		$('.buttons-wrapper').css('display','flex');
1690		$('.mobile_nav_collapse').css('display','none');
1691		$('.nav_section_label').removeClass('clicked');
1692		$('.nav_section_container').removeClass('clicked');
1693		$('.nav-tab-element').delay(4000).removeClass('selected-nav-element');
1694	}
1695
1696
1697});
1698
1699$('.theme-slider-container > a').click(function(e) {
1700$('.active-slide').removeClass('active-slide');
1701$(this).addClass('active-slide');
1702
1703})
1704
1705$('.cln-section-2 .cln-secondary-article').click(function(e) {
1706	var currentTarget = $(e.currentTarget);
1707	var initSocialLink = $('.active-video').data('social-url');
1708	var url = currentTarget.data("url");
1709	var poster = currentTarget.data("poster");
1710	var videoTitle = currentTarget.data("title");
1711	var blogUrl = currentTarget.data("post_url");
1712	var socialLink = currentTarget.data("social-url");
1713	var dataCategory = currentTarget.data("category");
1714	var categoryLink = currentTarget.data("category-slug");
1715
1716	//Take out data info
1717	$('.cln-secondary-article').removeClass("active-video");
1718	currentTarget.addClass("active-video");
1719	$('.cln-video').attr({
1720		"src" : url,
1721		"poster" : "",
1722		"autoplay" : "",
1723	});
1724	$('.cln-section-2 .cln-left-section .cln-article-title').text(videoTitle);
1725	$('.cln-section-2 .cln-left-section .category').text(dataCategory);
1726
1727	$('.video-title, .cln-section-2 .cln-read-more a').attr("href", blogUrl);
1728	$('.cln-category-link').attr("href", categoryLink);
1729
1730
1731	$('.cln-section-2 .share_btn').each(function() {
1732		var href = $(this).attr("href");
1733		href = href.replace(initSocialLink, socialLink);
1734		$(this).attr("href", href)
1735		//replace old href with new
1736	})
1737
1738});
1739
1740$('#scroller_fixed').hide();
1741
1742$(window).scroll(function() {
1743	var scrollVal = $(this).scrollTop();
1744	if(scrollVal < 600) {
1745		$('#scroller_fixed').fadeOut();
1746	} else {
1747		$('#scroller_fixed').fadeIn();
1748	}
1749})
1750
1751function scrollToProductSection(targetElement){
1752		var element = $(targetElement)[0];
1753
1754		var headerOffset = 50;
1755		var elementPosition = element.getBoundingClientRect().top;
1756		var offsetPosition = elementPosition + window.pageYOffset - headerOffset;
1757
1758		window.scrollTo({
1759				 top: offsetPosition,
1760				 behavior: "smooth"
1761		});
1762}
1763
1764$(".product-sticky-nav a").click(function(e) {
1765	e.preventDefault();
1766	let current_url = window.location.href.split("#")[0];
1767	document.location.hash = $(this).data('tag');
1768
1769
1770	 scrollToProductSection($(this).attr('href'));
1771
1772})
1773
1774$('.growth-section .performance-button').click(function() {
1775	$('.growth-section .performance-button').css('color', 'white');
1776	$('.growth-section .performance-clicked').css('color', fundThemeColor);
1777})
1778
1779$(window).scroll(function (e) {
1780var windowTop = $(this).scrollTop();
1781$('.product-sticky-nav a').each(function (event) {
1782		if (windowTop >= $($(this).attr('href')).offset().top - 100) {
1783				$('.active-product-section').removeClass('active-product-section');
1784				$(this).addClass('active-product-section');
1785		}
1786});
1787
1788})
1789
1790
1791let scriptsAppended = false;
1792$('.cln-form input, .cmn-form input, .kraneshares-form input, .europe-form input, .kfa-form input').focus(function() {
1793	if(!scriptsAppended) {
1794			if(kraneSite === "chinalastnight") {
1795				$('#mc_embed_signup').after(`
1796									 <script type="text/javascript" src="https://s3.amazonaws.com/downloads.mailchimp.com/js/mc-vali
1796date.js"></script>
1797									 <script type="text/javascript">
1798											 (function($) {
1799													 window.fnames = new Array();
1800													 window.ftypes = new Array();
1801													 fnames[0]='EMAIL'; ftypes[0]='email';
1802													 fnames[1]='FNAME'; ftypes[1]='text';
1803													 fnames[2]='LNAME'; ftypes[2]='text';
1804													 fnames[4]='MMERGE4'; ftypes[4]='text';
1805													 fnames[8]='MMERGE8'; ftypes[8]='radio';
1806													 fnames[9]='MMERGE9'; ftypes[9]='text';
1807													 fnames[10]='MMERGE10'; ftypes[10]='text';
1808													 fnames[11]='MMERGE11'; ftypes[11]='text';
1809													 fnames[3]='MMERGE3'; ftypes[3]='text';
1810													 fnames[5]='MMERGE5'; ftypes[5]='text';
1811													 fnames[6]='MMERGE6'; ftypes[6]='text';
1812													 fnames[7]='MMERGE7'; ftypes[7]='text';
1813											 })(jQuery);
1814											 var $mcj = jQuery.noConflict(true);
1815									 </script>
1816					`);
1817					scriptsAppended = true;
1818	} else if(kraneSite === "climatemarketnow") {
1819		$('#mc_embed_signup').after(`
1820							 <script type="text/javascript" src="https://s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js"></script>
1821							 <script type="text/javascript">
1822									 (function($) {
1823											 window.fnames = new Array();
1824											 window.ftypes = new Array();
1825											 fnames[0]='EMAIL';ftypes[0]='email';
1826											 fnames[1]='FNAME3';ftypes[1]='text';
1827											 fnames[2]='LNAME3';ftypes[2]='text';
1828											 fnames[4]='PHONE3';ftypes[4]='phone';
1829											 fnames[5]='FINPROF3';ftypes[5]='radio';
1830											 fnames[6]='MMERGE5';ftypes[6]='text';
1831											 fnames[7]='MMERGE7';ftypes[7]='text';
1832											 fnames[8]='MMERGE8';ftypes[8]='text';
1833											 fnames[3]='ADDRESS';ftypes[3]='address';
1834									 })(jQuery);
1835									 var $mcj = jQuery.noConflict(true);
1836							 </script>
1837			`);
1838			scriptsAppended = true;
1839		} else if(kraneSite === "kraneshares") {
1840	  			$('#mc_embed_signup').after(`
1841	  								 <script type="text/javascript" src="https://s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js"></script>
1842	  								 <script type="text/javascript">
1843	  										 (function($) {
1844	  												 window.fnames = new Array();
1845	  												 window.ftypes = new Array();
1846	  												 fnames[1]='FNAME5';ftypes[1]='text';
1847	                           fnames[2]='LNAME5';ftypes[2]='text';
1848	                           fnames[0]='EMAIL';ftypes[0]='email';
1849	                           fnames[4]='PHONE5';ftypes[4]='phone';
1850	                           fnames[7]='INT5';ftypes[7]='dropdown';
1851	                           fnames[3]='FINPROF5';ftypes[3]='radio';
1852	                           fnames[5]='ADSOURCE5';ftypes[5]='text';
1853	                           fnames[6]='PAGE5';ftypes[6]='text';
1854	                           fnames[8]='MMERGE8';ftypes[8]='text';
1855	  										 })(jQuery);
1856	  										 var $mcj = jQuery.noConflict(true);
1857	  								 </script>
1858	  				`);
1859				scriptsAppended = true;
1860	    } else if(kraneSite === "kfafunds") {
1861		  			$('#mc_embed_signup').after(`
1862		  								 <script type="text/javascript" src="https://s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js"></script>
1863		  								 <script type="text/javascript">
1864		  										 (function($) {
1865		  												 window.fnames = new Array();
1866		  												 window.ftypes = new Array();
1867		  												fnames[0]='EMAIL';ftypes[0]='email';
1868															fnames[1]='FNAME';ftypes[1]='text';
1869															fnames[2]='LNAME';ftypes[2]='text';
1870															fnames[4]='PHONE';ftypes[4]='phone';
1871															fnames[15]='MMERGE15';ftypes[15]='radio';
1872															fnames[13]='MMERGE13';ftypes[13]='text';
1873															fnames[14]='MMERGE14';ftypes[14]='text';
1874															fnames[12]='MMERGE12';ftypes[12]='text';
1875															fnames[3]='ADDRESS';ftypes[3]='address';
1876															fnames[5]='MMERGE5';ftypes[5]='text';
1877															fnames[6]='MMERGE6';ftypes[6]='text';
1878															fnames[7]='MMERGE7';ftypes[7]='text';
1879															fnames[8]='MMERGE8';ftypes[8]='text';
1880															fnames[9]='MMERGE9';ftypes[9]='text';
1881															fnames[10]='MMERGE10';ftypes[10]='text';
1882															fnames[11]='MMERGE11';ftypes[11]='text';
1883		  										 })(jQuery);
1884		  										 var $mcj = jQuery.noConflict(true);
1885		  								 </script>
1886		  				`);
1887		          scriptsAppended = true;
1888		    } else if(kraneSite === "europe") {
1889			  			$('#mc_embed_signup').after(`
1890			  								 <script type="text/javascript" src="https://s3.amazonaws.com/downloads.mailchimp.com/js/mc-vali
1890date.js"></script>
1891			  								 <script type="text/javascript">
1892			  										 (function($) {
1893			  												 window.fnames = new Array();
1894			  												 window.ftypes = new Array();
1895																 fnames[1]='FNAME5';ftypes[1]='text';
1896																 fnames[2]='LNAME5';ftypes[2]='text';
1897																 fnames[0]='EMAIL';ftypes[0]='email';
1898																 fnames[4]='PHONE5';ftypes[4]='phone';
1899																 fnames[6]='INT5';ftypes[6]='dropdown';
1900																 fnames[3]='FINPROF5';ftypes[3]='radio';
1901																 fnames[5]='ADSOURCE5';ftypes[5]='text';
1902																 fnames[7]='MMERGE7';ftypes[7]='text';
1903																 fnames[8]='MMERGE8';ftypes[8]='text';
1904			  										 })(jQuery);
1905			  										 var $mcj = jQuery.noConflict(true);
1906			  								 </script>
1907			  				`);
1908			          scriptsAppended = true;
1909			    }
1910}
1911});
1912$('#krane-privacy-policy-checkbox').on('change', function () {
1913    if ($(this).is(':checked')) {
1914			$('.checkbox-wrapper-4 .cbx').removeClass('unchecked-warning');
1915    }
1916});
1917
1918
1919let specialFieldAppended = false;
1920let validAdsource = false;
1921let userHasCheckedBox = false;
1922
1923$('#mc-embedded-subscribe').click(function(e) {
1924
1925	for(let i=0; i< approvedAdsources.length; i++) {
1926		if(approvedAdsources[i].adsource === $('.adsource').val() || $('.adsource').val() === 'NA' || $('.adsource').val() === '') {
1927			// if($('#mce-error-response').is(':hidden')) {
1928			// 	$('#mc_embed_signup #mce-success-response').text('Thank y
1928ou for subscribing!').fadeIn();
1929			// }
1930			userMcEmail = $('#mce-EMAIL').val();
1931			$('.tm-email').attr('id', userMcEmail);
1932			validAdsource = true;
1933			break;
1934		}
1935	}
1936	//extra step on CLN:
1937	if ($("#cln-special-fields").length && !specialFieldAppended && validAdsource) {
1938		$("#cln-special-fields").append('<input type="text" name="MMERGE11" class="text" id="mce-MMERGE11" value="special question">');
1939		specialFieldAppended = true;
1940	} else if($("#cmn-special-fields").length && !specialFieldAppended && validAdsource) {
1941				$("#cmn-special-fields").append('<input type="text" name="MMERGE8" class=" text" id="mce-MMERGE8" value="special question">');
1942				specialFieldAppended = true;
1943	} else if($("#kraneshares-special-fields").length && !specialFieldAppended && validAdsource) {
1944				$("#kraneshares-special-fields").append('<input type="text" name="MMERGE8" class=" text" id="mce-MMERGE8" value="special question">');
1945				specialFieldAppended = true;
1946	} else if($("#kfa-special-fields").length && !specialFieldAppended && validAdsource) {
1947				$("#kfa-special-fields").append('<input type="text" name="MMERGE12" class=" text" id="mce-MMERGE12" value="special question">');
1948				specialFieldAppended = true;
1949	} else if($("#europe-special-fields").length && !specialFieldAppended && validAdsource) {
1950				$("#europe-special-fields").append('<input type="text" name="MMERGE8" class=" text" id="mce-MMERGE8" value="special question">');
1951				specialFieldAppended = true;
1952	}
1953	//do below on all sites:
1954	function toE164NoRegex(phoneNumber, countryCode = '1') {
1955	  let cleaned = '';
1956	  // Loop through characters and keep only digits
1957	  for (let i = 0; i < phoneNumber.length; i++) {
1958	    const char = phoneNumber[i];
1959	    if (char >= '0' && char <= '9') {
1960	      cleaned += char;
1961	    }
1962	  }
1963
1964	  // Prepend '+' and country code
1965	  return '+' + countryCode + cleaned;
1966	}
1967
1968	//verify user has checked box:
1969	if($('#krane-privacy-policy-checkbox').is(':checked') || !$('#krane-privacy-policy-checkbox').length) { //checkd box OR there is no box.
1970		userHasCheckedBox = true;
1971	} else if(!$('#krane-privacy-policy-checkbox').is(':checked') && $('#krane-privacy-policy-checkbox').length) { //checkbox exists but not checked
1972		$('.checkbox-wrapper-4 .cbx').addClass('unchecked-warning');
1973		userHasCheckedBox = false;
1974	}
1975
1976	if (validAdsource && userHasCheckedBox) {
1977
1978		//do advanced conversion insert to data layer here:
1979		let gTagEmail = $('#mce-EMAIL').val();
1980		let rawPhone = $('#mc_embed_signup input[id*="phone" i]').val();
1981		let gTagPhone = toE164NoRegex(rawPhone);
1982		dataLayer.push({
1983			'event':'ec_formsubmit',
1984			'enhanced_conversion_data': {
1985				"email": gTagEmail,
1986				"phone_number": gTagPhone
1987			}
1988		})
1989
1990			 return true;
1991	}
1992			e.preventDefault();
1993
1994
1995});
1996
1997
1998
1999$('#cfa-select').change(function(e) {
2000	var replacement_adsource = $('#cfa-select option:selected').val();
2001	$('#mce-MMERGE5').attr('value', replacement_adsource);
2002})
2003
2004var	hideStickyNav = false;
2005$(window).scroll(function (e) {
2006	var windowTop = $(this).scrollTop();
2007	$('.product-sticky-nav a').each(function (event) {
2008			if (windowTop >= $($(this).attr('href')).offset().top - 100) {
2009					$('.active-product-section').removeClass('active-product-section');
2010					$(this).addClass('active-product-section');
2011					if( !hideStickyNav) {
2012						$('.product-sticky-nav .fa-times').css('display', 'block');
2013					} else if(hideStickyNav) {
2014						$('.product-sticky-nav .fa-times').css('display', 'none');
2015					}
2016			}
2017	});
2018})
2019$('.product-sticky-nav .fa-times').click(function() {
2020	$('.product-sticky-nav').addClass('collapsed-sticky-nav').stop().animate({width:40}, 100);
2021	$('.product-sticky-nav a, .product-sticky-nav .fa-times, .outcome-period-dropdown, .outcome-period-tool-div').css('display', 'none');	$('.product-sticky-nav .fa-caret-right').addClass('product-right-arrow');
2022	setCookie('sticky-nav', 'closed', 30);
2023
2024	hideStickyNav = true;
2025})
2026$('.product-sticky-nav .fa-caret-right').click(function() {
2027	$('.product-sticky-nav .fa-caret-right').removeClass('product-right-arrow');
2028	$('.product-sticky-nav').removeClass('collapsed-sticky-nav').stop().animate({width:'100%'}, 100);
2029	$('.product-sticky-nav a:not(.no-show), .outcome-period-dropdown, .outcome-period-tool-div').fadeIn();
2030	setCookie('sticky-nav', 'open', 30);
2031
2032	hideStickyNav = false;
2033})
2034
2035
2036
2037
2038var currentSlide = $('.active-slide .fas').data('slide-control');
2039var slideObserver = new IntersectionObserver(function(entries) {
2040	// isIntersecting is true when element and viewport are overlapping
2041	// isIntersecting is false when element and viewport don't overlap
2042			for (var i=0;i<entries.length;i++) {
2043				if(entries[i].isIntersecting === true) {
2044
2045					var targetId = $(entries[i].target).attr('id');
2046					if(currentSlide != targetId) {
2047
2048						currentSlide = targetId;
2049
2050						$('.active-slide').removeClass('active-slide');
2051						$('.theme-slider-container a[href$=' + targetId + ']').addClass('active-slide');
2052
2053				}
2054			}
2055		}
2056
2057}, {
2058		threshold: [1],
2059		root: document.querySelector(".explore-themes-container"),
2060		}
2061);
2062
2063document.querySelectorAll(".single-theme").forEach((i) => {
2064		if (i) {
2065				slideObserver.observe(i);
2066		}
2067	})
2068
2069// root is the browser viewport / screen
2070var observer = new IntersectionObserver(function(entries) {
2071	// isIntersecting is true when element and viewport are overlapping
2072	// isIntersecting is false when element and viewport don't overlap
2073	if(entries[0].isIntersecting === true) {
2074		$('.fa-times').css('display', 'none');
2075		if(!hideStickyNav) {
2076			$('.product-sticky-nav .fa-caret-right').removeClass('product-right-arrow');
2077			$('.product-sticky-nav').removeClass('collapsed-sticky-nav').stop().animate({width:'100%'}, 100);
2078			$('.product-sticky-nav a:not(.no-show)').css('display', 'block');
2079				// hideStickyNav = false;
2080		}
2081	}	else if(getCookie('sticky-nav') === "closed" && !$('.product-sticky-nav').hasClass('outcome-tool') && entries[0].isIntersecting === false) {
2082
2083		$('.product-sticky-nav .fa-times').click();
2084	}
2085}, { threshold: [0] });
2086
2087if(document.querySelector(".product-banner")) {
2088	observer.observe(document.querySelector(".product-banner"));
2089}
2090if(document.querySelector("#outcome-banner")) {
2091	observer.observe(document.querySelector("#outcome-banner"));
2092}
2093$('.one-year-documents-container, .one-year-documents').hide();
2094$('.ticker-container .individual-fund').map(function() {
2095	let ticker = $(this).data('ticker');
2096	let foundMatchingDocument = $(`.one-year-documents a[data-ticker=${ticker}]`);
2097	if(!foundMatchingDocument.length) {
2098		$(this).hide();
2099	}
2100
2101})
2102
2103$('.ticker-container .individual-fund').click(function(e) {
2104	$('.ticker-container .individual-fund').removeClass('selected');
2105	$(this).addClass('selected');
2106	let ticker = $(this).data('ticker');
2107	let altTicker;
2108	let disclaimerText;
2109	$('.one-year-documents-container, .tax-year-heading, .one-year-documents, .one-year-documents a, .no-documents-message , .one-year-documents-container .disclaimer').hide();
2110	let documentsFound = false;
2111	if(ticker === 'kbnd') {
2112		altTicker = 'kcny'
2113		$('.one-year-documents-container .disclaimer').text('* KBND is formerly the KraneShares E Fund China Commercial Paper ETF (KCNY) as of June 4, 2021.');
2114	} else if(ticker === 'khyb') {
2115			altTicker = 'kccb'
2116			$('.one-year-documents-container .disclaimer').text('* KHYB is formerly the KraneShares Asia Pacific High Yield Bond ETF, and prior to August 2, 2021, the KraneShares CCBS China Corporate High Yield Bond USD Index ETF (ticker: KCCB).');
2117	}
2118
2119	$('.one-year-documents a').map(function() {
2120		$('.one-year-documents-container').show();
2121
2122		if($(this).data('ticker') === ticker || $(this).data('ticker') === altTicker ) {
2123			documentsFound = true;
2124			$(this).show()
2125						 .parent()
2126						 .show()
2127						 .find('.tax-year-heading')
2128						 .show();
2129			if(altTicker) {
2130				$('.one-year-documents-container .disclaimer').show();
2131			}
2132		}
2133	})
2134	if(!documentsFound) {
2135		$('.no-documents-message').fadeIn();
2136	}
2137})
2138
2139$('.individual-fund.selected-fund').click();
2140
2141//only enable search button in search bar when a user has typed something in.
2142$('.search_field').on('input', function() {
2143 if ($(this).val().trim() !== '') {
2144	 $('.search_button').prop('disabled', false);
2145	 $('.icon-form-submit').removeClass('disabled');
2146 } else {
2147	 $('.search_button').prop('disabled', true);
2148	 $('.icon-form-submit').addClass('disabled');
2149 }
2150});
2151
2152$('.defined-promo-box').fadeIn(2000).css('display', 'flex');
2153
2154$('.underlying-index').click(() => {
2155	scrollTo('#product_performance .disclosure_box');
2156})
2157
2158
2159
2160$('.show-top-monthly-returns').on('click', function() {
2161
2162$('.monthly-performance-hidden-row').toggleClass('hidden');
2163$('.show-more-btn .btn-show').toggleClass('hidden');
2164$('.show-more-btn .btn-hide').toggleClass('hidden');
2165
2166});
2167//top 10 holding
2168 $('.show-top-10-holding-btn-show, .show-top-10-holding-btn-hide').on('click', function () {
2169
2170    $('.top-10-hidden-row').toggleClass('hidden');
2171    $('.show-top-10-holding-btn-show').toggleClass('hidden');
2172    $('.show-top-10-holding-btn-hide').toggleClass('hidden');
2173
2174});
2175$('.ticker-tape .fa-times').on('click', (e) => {
2176	e.preventDefault();
2177	$('.ticker-tape').slideUp(300);
2178})
2179
2180$('.ticker-tape').on('click', (e) => {
2181	setCookie('ticker-message-esc', $('.ticker-tape').data('id'), 60);
2182})
2183
2184$('#19a-redirect').on('click', function(e) {
2185    e.preventDefault();
2186    $('#download_links a').each(function() {
2187			if ($(this).attr('href')?.includes('19a.notice.pdf')) {
2188					this.click();
2189					return false;
2190			}
2191    });
2192});
2193
2194let footerPopCookieCheck = getCookie('footer-pop');
2195let krane_pc_CookieCheck = getCookie('krane_pc');
2196let CountryCodeCookieCheck = getCookie('cc');
2197let performance_cookies_accepted = true;
2198let performance_cookies_mandatory = false;
2199
2200
2201if( kraneSite === 'kraneshares' || kraneSite === 'europe' || kraneSite === 'kfafunds' || kraneSite === "chinalastnight" || kraneSite === 'climatemarketnow' )  {
2202	// these sites always need accepted performance cookies
2203	performance_cookies_mandatory = true;
2204
2205	if(krane_pc_CookieCheck === 'deny' || (!krane_pc_CookieCheck && !footerPopCookieCheck) ) {
2206		performance_cookies_accepted = false;
2207
2208		//the cookie was set
2209	}
2210}
2211
2212
2213
2214if( (performance_cookies_mandatory && performance_cookies_accepted) || (kraneSite == "europe" && CountryCodeCookieCheck) || (kraneSite != "europe" && !performance_cookies_mandatory) ) {
2215	gtag('consent', 'update', {'analytics_storage': 'granted','ad_storage':'granted','ad_personalization':'granted','ad_user_data':'granted','personalization_storage': 'granted'});
2216	//add condition here? if google tags exist
2217	//check dataLayer || check var f
2218	var hasGTM = window.dataLayer && Array.isArray(window.dataLayer) && window.dataLayer.some(function(entry) {
2219               return entry.event === 'gtm.js';
2220             });
2221	if (!hasGTM) {
vendor: 351 bytes, lines 2221-2227
2221
2222		(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});
2223			var f=d.getElementsByTagName(s)[0],
2224			j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;
2225			j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
2226			f.parentNode.insertBefore(j,f);
2227		})(window,document,'script','dataLayer','
2227GTM-P7D44FW
vendor: 9 bytes, lines 2227-2229
2227');
2228
2229		
2229hasGTM = window.dataLayer && Array.isArray(window.dataLayer) && window.dataLayer.some(function(entry) {
2230               return entry.event === 'gtm.js';
2231             });
2232	}
2233
2234	var hasLinkedIn = window.lintrk;
2235
2236	if (!hasLinkedIn) {
2237		(function(l) {
2238        if (!l){window.lintrk = function(a,b){window.lintrk.q.push([a,b])};
2239        window.lintrk.q=[]}
2240        var s = document.getElementsByTagName("script")[0];
2241        var b = document.createElement("script");
2242        b.type = "text/javascript";b.async = true;
2243        b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js";
2244        s.parentNode.insertBefore(b, s);})(window.lintrk);
2245	}
2246
2247	var hasRedditScript = $('script[src*="redditstatic"]').length > 0;
2248
2249	if (!hasRedditScript) {
2250		!function(w,d){if(!w.rdt){var p=w.rdt=function(){p.sendEvent?p.sendEvent.apply(p,arguments):p.callQueue.push(arguments)};p.callQueue=[];var t=d.createElement("script");t.src="https://www.redditstatic.com/ads/pixel.js",t.async=!0;var s=d.getElementsByTagName("script")[0];s.parentNode.insertBefore(t,s)}}(window,document);rdt('init','a2_hj6l5m7f7k5z');rdt('track', 'PageVisit');
2251	}
2252
2253
2254}
2255
2256$('.category-dropdown-toggle').on('click', function(e) {
2257	e.stopPropagation();
2258
2259	const $menu = $(this).next('.category-dropdown-menu');
2260	const isOpen = $menu.is(':visible');
2261
2262	$('.category-dropdown-menu').hide(); // close others
2263	$('.category-dropdown-toggle').removeClass('open');
2264
2265	if (!isOpen) {
2266		$menu.show();
2267		$(this).addClass('open');
2268	}
2269});
2270
2271// Close dropdown when clicking outside
2272$('.archive').on('click', function() {
2273	$('.category-dropdown-menu').hide();
2274	$('.category-dropdown-toggle').removeClass('open');
2275});
2276
2277$('.kraneshares-themes ul').on('click', 'li:not(.active):not(.explore-link)', function(e) {
2278	 currentTheme = $(this).data('theme');
2279	 //delete after proxy vote:
2280	 if( currentTheme === 'proxy-vote' ) {
2281  		$('.explore-kraneshares-etfs h2').css("visibility" , "hidden");
2282 			$('.kraneshares-theme-details a').attr('href', '/proxy-vote').html('Vote Now <em>â­¢</em>');
2283  	} else {
2284  		$('.explore-kraneshares-etfs h2').css("visibility" , "visible");
2285 			$('.kraneshares-theme-details a').attr('href', '/' + currentTheme + '-etfs').html('Explore <em>â­¢</em>');
2286  	}
2287
2288	 $('.kraneshares-theme-details .active, .kraneshares-themes .active').removeClass('active');
2289	 $(this).addClass('active');
2290	 $('.kraneshares-theme-details .details[data-theme="' + currentTheme + '"]').addClass('active');
2291
2292	 var $img = $('.explore-kraneshares-etfs img');
2293	 var newSrc = $img.attr('src').replace(/images\/.*?_preview/, 'images/' + currentTheme + '_preview');
2294	 $img.attr('alt', 'Image showing KraneShares ' + currentTheme + ' for global investors');
2295
2296	 // Create a temporary image to preload
2297	 var imgPreload = new Image();
2298	 imgPreload.onload = function() {
2299			 $img.css('opacity', 0) // hide without collapsing
2300					 .attr('src', newSrc)
2301					 .animate({opacity: 1}, 800); // fade in after fully loaded
2302	 };
2303	 imgPreload.src = newSrc; // start loading
2304
2305	 var currentSlug = $(this).data('slug');
2306	 if(kraneSite === "europe" && currentSlug === 'carbon-credit') {
2307	 		$('.kraneshares-theme-details a').attr('href', '/' + currentSlug + '-etcs');
2308 		} else if(currentSlug === 'proxy-vote') {
2309			$('.kraneshares-theme-details a').attr('href', '/' + currentSlug);
2310		} else {
2311			$('.kraneshares-theme-details a').attr('href', '/' + currentSlug + '-etfs');
2312		}
2313
2314})
2315var startX = 0;
2316var endX = 0;
2317var isSwiping = false;
2318var swipeThreshold = 50;
2319
2320// Cache all valid theme dots (exclude "View All ETFs")
2321var $themes = $('.kraneshares-themes li:not(.explore-link)');
2322
2323function getActiveThemeIndex() {
2324  return $themes.index($('.kraneshares-themes li.active'));
2325}
2326
2327function activateThemeByIndex(index) {
2328  if (index < 0) {
2329    return;
2330  }
2331
2332  if (index >= $themes.length) {
2333    return;
2334  }
2335
2336  $themes.eq(index).trigger('click');
2337}
2338
2339// Touch start
2340$('.explore-kraneshares-etfs').on('touchstart', function (e) {
2341  if (window.innerWidth > 980) {
2342    return;
2343  }
2344
2345  startX = e.originalEvent.touches[0].clientX;
2346  isSwiping = true;
2347});
2348
2349// Touch move
2350$('.explore-kraneshares-etfs').on('touchmove', function (e) {
2351  if (!isSwiping) {
2352    return;
2353  }
2354
2355  endX = e.originalEvent.touches[0].clientX;
2356});
2357
2358// Touch end
2359$('.explore-kraneshares-etfs').on('touchend', function () {
2360  if (!isSwiping) {
2361    return;
2362  }
2363
2364  isSwiping = false;
2365
2366  var distance = startX - endX;
2367  var activeIndex = getActiveThemeIndex();
2368
2369  // Swipe left == next theme
2370  if (distance > swipeThreshold) {
2371    activateThemeByIndex(activeIndex + 1);
2372  }
2373
2374  // Swipe right == previous theme
2375  if (distance < -swipeThreshold) {
2376    activateThemeByIndex(activeIndex - 1);
2377  }
2378});
2379document.addEventListener("DOMContentLoaded", function () {
2380  // Select elements
2381	const cards = document.querySelectorAll('.cn-about-container .card, .explore-kraneshares-etfs');
2382  const tickers = document.querySelectorAll('.trending-fund, .private-fund-section');
2383
2384  // Merge NodeLists
2385  const elementsToObserve = [...cards, ...tickers];
2386
2387  // Single observer: add in-view when any part visible, remove only when fully invisible
2388  const observer = new IntersectionObserver(
2389    (entries) => {
2390      entries.forEach(entry => {
2391        if (entry.intersectionRatio > 0) {
2392          entry.target.classList.add('in-view');
2393        } else {
2394          entry.target.classList.remove('in-view');
2395        }
2396      });
2397    },
2398    { threshold: [0, 1] } // fires when fully invisible (0) or partially visible (>0)
2399  );
2400
2401  // Observe all elements
2402  elementsToObserve.forEach(el => observer.observe(el));
2403});
2404
2405
2406}(window.jQuery || window.$));

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.