PageSourceSearch

https://sportfreunde-stiller.de/3/js/functions.js?v=1202853

js sportfreunde-stiller.de collected 2026-10-02 10:42:59 UTC 71,458 bytes, 1,867 lines download raw bytes

1// sportfreunde-stiller.de | 3 | functions.js
2
3// ------------ scroll to 0 ------------ /
4// window.scrollTo(0,0);
5// window.onbeforeunload = function(){ window.scrollTo(0,0); };
6var cachecontrol = getCacheControl();
7
8function doCtrl() {
9    doLog("doCtrl()");
10	// hi ;)
11}
12
13function onPageReady() {
14	doLog("onPageReady");
15	getConf();
16    // initHeader();
17	initCarousels();
18    initEffects();
19	initTabs();
20    doTruncate('.text_truncate', 10);
21	initSvg();
22	if (main == "index") {
23		initNav();
24        hidePreloader();
25        // initMasonry();
26	}
27	initFancybox();
28    checkLinks();
29	onResize();
30	initResize();
31    sInit();
32	sRefresh();
33    lazySizes.init();
34}
35
36function onPageLoaded() {
37	doLog("onPageLoaded");
38	sRefresh();
39	setTimeout(function() { 
40        $('.carousel').flickity('resize');
41        initNewsletter();
42	}, 1500);
43	setTimeout(function() {
44		$('.carousel').flickity('resize');
45		initAudioplayer();
46	}, 5000);
47}
48
49/*
50(function() {
51    var overflowing = [];
52    document.querySelectorAll('*').forEach(function(el) {
53        if (el.offsetWidth > document.documentElement.offsetWidth) {
54            overflowing.push(el);
55        }
56    });
57    if (overflowing.length) {
58        console.group('[DEBUG] Elements wider than viewport:');
59        overflowing.forEach(function(el) { console.log(el); });
60        console.groupEnd();
61    } else {
62        console.log('[DEBUG] No elements wider than viewport found.');
63    }
64})();
65*/
66
67function hidePreloader() {
68	$('#loading-animation').removeClass("fadeIn");
69	$('#loading-animation').addClass("animated_manual_animation zoomOutUp");
70	$('#preloader').delay(500).fadeOut(500);
71
72	setTimeout(function() {
73		$('.header_norm .social .animated_manual').each( function() {
74			var elem = $(this);
75			if ( !elem.hasClass('visible') ) {
76				var animationDelay = elem.data('animation-delay');
77				var animation = elem.data('animation');
78				if ( animationDelay ) {
79					setTimeout(function(){
80						elem.addClass( animation + " animated_manual_animation visible" );
81					}, animationDelay);
82				} else {
83					elem.addClass( animation + " animated_manual_animation visible" );
84				}
85			}
86		});
87	}, 2000);
88    
89	$('#teaser .animated_manual').each( function() {
90		var elem = $(this);
91		if ( !elem.hasClass('visible') ) {
92			var animationDelay = elem.data('animation-delay');
93			var animation = elem.data('animation');
94			if ( animationDelay ) {
95				setTimeout(function(){
96					elem.addClass( animation + " animated_manual_animation visible" );
97				}, animationDelay);
98			} else {
99				elem.addClass( animation + " animated_manual_animation visible" );
100			}
101		}
102	});
103}
104
105function skipIntro() {
106	doScroll('#video');
107	volume_bg_video(0);
108}
109
110function onResize() {
111	Waypoint.refreshAll();
112}
113
114
115// ------------ skrollr ------------ //
116
117var s;
118var lastDocumentWidth = 0;
119var lastDocumentHeight = 0;
120var sRefreshTimeout;
121
122function sInit() {
123    s = skrollr.init({ forceHeight:false, mobileBreakpoint:860 });
124}
125
126function sRefresh() {
127    var width = $(document).width();
128    var height = $(document).height();
129    if (height !== lastDocumentHeight || width !== lastDocumentWidth) {
130        // only refresh if the size actually changed // console.log("document width/height has changed to: " + width + "/" + height);
131        lastDocumentWidth = width;
132        lastDocumentHeight = height;
133        clearTimeout(sRefreshTimeout);
134		sRefreshTimeout = setTimeout(doRefresh, 250);
135    }
136	initCopyButtons();
137    $(document.body).trigger("sticky_kit:recalc");
138}
139
140function doRefresh() {
141    s.refresh();
142    Waypoint.refreshAll();
143}
144
145// ------------ effects ------------ //
146
147function unSticky(el) {
148    $(el).slideUp("fast", function() { 
149        $(el).css({"position":"relative","top":"auto","display":"block"});
150        $(el).find(".close").remove();
151    });
152}
153
154function initEffects() {
155    initAnims();
156    if ($(window).width() > 720) {
157        // sticky-element needs a height, needs "sticky_kit:recalc" in sRefresh
158        /*
159        $(".stick_in_parent").stick_in_parent({
160            inner_scrolling: false,
161            bottoming: true,
162            offset_top: 80
163        });
164        */
165    }
166}
167    
168function initAnims() {
169	$.appear('.animated', { force_process:true });
170	$('.animated').on('appear', function() {
171		var elem = $(this);
172		var animation = elem.data('animation');
173		if (!elem.hasClass('visible')) {
174			var animationDelay = elem.data('animation-delay');
175			if (animationDelay) {
176				setTimeout(function() {
177					elem.addClass(animation + " visible");
178				}, animationDelay);
179			} else {
180				elem.addClass(animation + " visible");
181			}
182		}
183	});
184	$('.animated').on('disappear', function() {
185		var elem = $(this);
186		var animation = elem.data('animation');
187		if (elem.hasClass('visible')) {
188			elem.removeClass(animation + " visible");
189		}
190	});
191	$(window).on("load", function() {
192		$('.onstart').each(function() {
193			var elem = $(this);
194			if (!elem.hasClass('visible')) {
195				var animationDelay = elem.data('animation-delay');
196				var animation = elem.data('animation');
197				if (animationDelay) {
198					setTimeout(function() {
199						elem.addClass(animation + " visible");
200					}, animationDelay);
201				} else {
202					elem.addClass(animation + " visible");
203				}
204			}
205		});
206	});
207}
208
209function initAnimsManual(target) {
210	$(target).appear();
211	$(target).on('appear', function() {
212		var elem = $(this);
213		var animation = elem.data('animation');
214		if (!elem.hasClass('visible')) {
215			var animationDelay = elem.data('animation-delay');
216			if (animationDelay) {
217				setTimeout(function(){
218					elem.addClass(animation + " visible");
219				}, animationDelay);
220			} else {
221				elem.addClass(animation + " visible");
222			}
223		}
224	});
225}
226
227function doAnim(elem, effect, remove) {
228	if (remove === false) { 
229		$(elem).addClass("animated_manual_animation " + effect).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function() {});
230	} else {
231		$(elem).addClass("animated_manual_animation " + effect).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function() {
232			$(elem).removeClass("animated_manual_animation");
233			$(elem).removeClass(effect);
234		});
235		$(elem).removeClass('animated_manual');
236	}
237}
238
239function jump(elem) {
240	doAnim(elem, 'bounceOutUp');
241	setTimeout(function() { 
242		$(elem).removeClass("animated_manual_animation");
243        $(elem).removeClass('bounceOutUp');
244		$(elem).css("transform", "translate3d(0,-2000px,0)");
245	}, 950);
246	setTimeout(function() {
247		$(elem).css("transform", "none");
248		doAnim(elem, 'bounceInDown', true);
249	}, 3000);
250}
251
252// ------------ inits ------------ /
253
254// https://stackoverflow.com/questions/9038625/#answer-9039885, https://stackoverflow.com/questions/7944460/
255var isiOS = ['iPad Simulator','iPhone Simulator','iPod Simulator','iPad','iPhone','iPod'].includes(navigator.platform)||(navigator.userAgent.includes("Mac")&&"ontouchend"in document);
256var isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 && navigator.userAgent && navigator.userAgent.indexOf('CriOS') == -1 && navigator.userAgent.indexOf('FxiOS') == -1;
257var isSafariMac = false;
258
259function getConf() {
260	if (device == "") {
261		// http://stackoverflow.com/questions/3514784/
262		var ua = navigator.userAgent.toLowerCase(); doLog("ua: " + ua);
263        var vendor = navigator.vendor; doLog("vendor: " + vendor);
264		if (ua.match(/webos/i)) { device = "webos"; }
265		if (ua.match(/opera mini/i)) { device = "opera mini"; }		
266		if (ua.match(/mobile/i)) { device = "mobile"; }
267		if (ua.match(/ipad/i)) { device = "ipad"; }
268		if (ua.match(/ipod|iphone/i)) { device = "iphone"; }
269		if (ua.match(/blackberry/i)) { device = "blackberry"; }
270		if (ua.match(/android/i)) { device = "android"; }
271		if (ua.match(/kindle/i)) { device = "kindle"; }
272		if (ua.match(/windows phone/i)) { device = "windows phone"; }
273		if (ua.match(/iemobile/i)) { device = "iemobile"; }
274		if (ua.match(/tablet/i)) { device = "tablet"; }
275    }
276    if (isSafari && isiOS) {
277        isSafariMac = false; doLog("safari on ios");
278    } else {
279        if (isSafari) { isSafariMac = true; doLog("safari on mac"); }
280    }
281	doLog("getConf() -> device: " + device);
282	if (device === "ipad" || device === "tablet") { $("#viewport_id").attr("content", "width=device-width, initial-scale=1"); } // set viewport
283	if (device !== "") {
284		$("#body_id").removeClass("desktop").addClass("device"); // set body-class, default: desktop
285	}
286	if (isiOS) {
287		$("#body_id").addClass("iOS");
288	}
289}
290
291
292// ------------------------ gallery ------------------------ //
293var $grid;
294
295var masonryOptions = {
296    itemSelector: '.grid-item',
297    // columnWidth: 80,
298    gutter: 30
299};
300
301function initMasonry() {
302	$grid = $('.grid').masonry(masonryOptions);
303}
304
305function destroyMasonry() {
306	$grid.masonry('destroy');
307}
308
309
310// ------------ load section-content ------------ //
311function getItems(section,type,subtype) {
312	doLog("getItems('" + section + "," + type + "," + subtype + "')");
313	saveHistory(section,type,subtype,"");
314	$.ajax({
315		url: "/" + base + "/section_" + section + "_get_items.php",
316		data: "section=" + section + "&type=" + type + "&subtype=" + subtype + "&lang=" + lang + "&device=" + device + "&country=" + country,
317		method: "GET",
318		dataType: "html",
319		cache: false,
320		beforeSend: function() {
321			$("#" + section + "_items_status").html('<div class="loading"><div class="spinner" role="status"></div></div>');
322			$("#" + section + " ul.sub_nav li").removeClass("on");
323			$("#" + section + " ul.sub_nav li .tab").removeAttr("aria-current");
324			$("#" + section + " ul.sub_nav li .tab").removeAttr("tabindex");
325			$("#" + section + "_items").empty();
326            if (section == "gallery") {
327                destroyMasonry();
328                $('.grid').empty();
329            }
330		},
331		success: function(data) {
332			$("#" + section + "_items_status").html('');
333			$("#" + section + " ul.sub_nav li.type" + type).addClass("on");
334			$("#" + section + " ul.sub_nav li.type" + type + " .tab").attr("aria-current",true);
335			$("#" + section + " ul.sub_nav li.type" + type + " .tab").attr("tabindex","-1");
336            if (section == "gallery") {
337                initMasonry();
338                var $content = $(data);
339                $grid.append($content).masonry('appended', $content);
340                setTimeout(function(){ $grid.masonry(); }, 100);
341            } else {
342                $("#" + section + "_items").append(data);
343				setTimeout(function() { $("#" + section + "-itemlist-a").find("li:first-child a").trigger("focus"); }, 500);
344                initSvg("#" + section);
345            }
346		},
347		error: function(XMLHttpRequest, textStatus, errorThrown) {
348			// alert("Error:" + errorThrown + "(" + XMLHttpRequest.status + ")");
349		},
350		complete: function() {
351			sRefresh();
352		}
353	});
354}
355
356function getMoreItems(section,start,limit,type,subtype,id,modus) {
357	doLog("getMoreItems('" + section + "," + start + "," + limit + "," + type + "," + subtype + "," + id + "," + modus + "')");
358	if (start < 0) { start = 0; }
359	$.ajax({
360		url: "/" + base + "/section_" + section + "_get_items.php",
361		data: "section=" + section + "&start=" + start + "&limit=" + limit + "&type=" + type + "&subtype=" + subtype + "&id=" + id + "&lang=" + lang + "&device=" + device + "&country=" + country,
362		method: "GET",
363		dataType: "html",
364		cache: false,
365		beforeSend: function() {
366			$("#" + section + "_items .more").html('<div class="loading"><div class="spinner" role="status"></div></div>');
367		},
368		success: function(data) {
369			if (modus === "clear") {
370				$("#" + section + "_items ul.itemlist").empty().append(data);
371			} else {
372                if (section == "gallery") {
373                    var $content = $(data);
374                    $grid.append($content).masonry('appended', $content);
375                    setTimeout(function(){ $grid.masonry(); }, 100);
376                } else {
377                    $("#" + section + "_items ul.itemlist").append(data);
378					// setTimeout(function() { $("#" + section + "-itemlist-a").find("li:first-child a").trigger("focus"); }, 500);
379                    initSvg("#" + section);
380                }
381			}
382		},
383		error: function(XMLHttpRequest, textStatus, errorThrown) {
384			// alert("Error:" + errorThrown + "(" + XMLHttpRequest.status + ")");
385		},
386		complete: function() {
387			sRefresh();
388		}
389	});
390}
391
392function toggleItems(event,target) {
393	var toggle_link = $(event.target);
394	var collapse_item = $("#" + toggle_link.attr("aria-controls"));
395	var scrollpoint = $("#" + toggle_link.data("scrollpoint"));
396	// console.log(event.target); console.log("collapse_item: " + toggle_link.attr("aria-controls")); console.log("scrollpoint: " + toggle_link.data("scrollpoint"));
397	if (collapse_item.hasClass('on')) {
398        // close target item
399        collapse_item.slideUp("fast", function() {
400			collapse_item.removeClass('on');
401            toggle_link.attr("aria-expanded","false");
402			toggle_link.html(urldecode(toggle_link.data("desc-off")));
403            doScroll(scrollpoint);
404			sRefresh();
405			setTimeout(function() { 
406				scrollpoint.find("li:first-child a").trigger("focus");
407			}, 1000);
408        });
409    } else {
410        // open target item
411        collapse_item.slideDown("slow", function() {
412			collapse_item.addClass('on');
413            toggle_link.attr("aria-expanded","true");
414			toggle_link.html(urldecode(toggle_link.data("desc-on")));
415            doScroll(collapse_item);
416			sRefresh();
417			setTimeout(function() { 
418				collapse_item.find("li:first-child a").trigger("focus");
419			}, 1000);
420        });
421    }
422}
423
424function getItem(section,type,subtype,id,autoplay) {
425	doLog("getItem(" + section + "," + type + "," + subtype + "," + id + "," + autoplay + ")");
426	saveHistory(section,type,subtype,id);
427	var ausdruck = /^(\d*)?$/;   // \d = digit, \w = word, ? = egal wievielmal vorher (zb. egal wieviel buchstaben)
428	if (ausdruck.exec(id)) {
429		// alert("valid request ->\n id:" + RegExp.$1);
430		var id = RegExp.$1;
431		var feedback_id = "#" + section + "_container";
432		$.ajax({
433			url: "/" + base + "/section_" + section + "_get_item.php",
434			data: "type=" + type + "&subtype=" + subtype + "&id=" + id + "&autoplay=" + autoplay + "&lang=" + lang + "&device=" + device + "&country=" + country,
435			method: "GET",
436			dataType: "html",
437			cache: false,
438			beforeSend: function() {
439				$("#" + section + " ul.sub_nav li").removeClass("on");
440				$("#" + section + " ul.sub_nav li .tab").removeAttr("aria-current");
441				$("#" + section + " ul.sub_nav li .tab").removeAttr("tabindex");
442                $("#" + section + "_holder").removeClass(function (index, className) { return (className.match (/(^|\s)type-\S+/g) || []).join(' '); }); // https://stackoverflow.com/questions/2644299/
443                $("#" + section + "_holder").addClass("type-" + type);
444				$("#" + section + "_holder").slideDown(1000);
445				$("#" + section + "_title").empty().append("Loading...");
446				$(feedback_id).html('<div class="loading"><div class="spinner" role="status"></div></div>');
447			},
448			success: function(data) {
449				$("#" + section + " ul.sub_nav li.type" + type).addClass("on");
450				$("#" + section + " ul.sub_nav li.type" + type + " .tab").attr("aria-current",true);
451				$("#" + section + " ul.sub_nav li.type" + type + " .tab").attr("tabindex","-1");
452				$(feedback_id).empty().append(data);
453                initSvg(feedback_id);
454			},
455			error: function(XMLHttpRequest, textStatus, errorThrown) {
456				// alert("Error:" + errorThrown + "(" + XMLHttpRequest.status + ")");
457			},
458			complete: function() {
459				sRefresh();
460			}
461		});
462	} else {
463		alert("invalid request");
464	}
465}
466
467function setItem(section, id, txt) {
468	doLog("setItem(" + section + "," + id + "," + txt + ")");
469	if (section === "video") {
470		$("#video_title").empty().append(urldecode(txt));
471		if (userInteraction) {
472			setTimeout(function() {
473				$("#video_container iframe")[0].focus();
474			}, 1500);
475		}
476	} else {
477		if (userInteraction) {
478			$("#" + section + "_container").focus();
479		}
480	}
481	$("." + section + "_items ul li").removeClass("on");
482	$("." + section + "_items ul li a").removeAttr("aria-current");
483	$("." + section + "_items ul li a").removeAttr("tabindex");
484	$("." + section + "_items ul li.item" + id).addClass("on");
485	$("." + section + "_items ul li.item" + id + " a").attr("aria-current",true);
486	$("." + section + "_items ul li.item" + id + " a").attr("tabindex","-1");
487	sRefresh();
488}
489
490// ------------------------ history ------------------------ //
491var userInteraction = false;
492
493function getContent(itemLang,itemSection,itemName,itemType,itemSubtype,itemId,itemStart) {
494	doLog("getContent(" + itemLang + "," + itemSection + "," + itemName + "," + itemType + "," + itemSubtype + "," + itemId + "," + itemStart + ")");
495	userInteraction = true;
496	doStop();
497	var data = {lang:itemLang,section:itemSection,type:itemType,subtype:itemSubtype,id:itemId,start:itemStart};
498	var theTitle = itemLang + "|" + itemSection + "|" + itemType + "|" + itemSubtype + "|" + itemId + "|" + itemStart;	
499	var theUrl = "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html";
500	// base + "/" + // + itemLang + "/"
501	// var theUrl = "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html"; // special: itemLang always "en"
502	if (itemName == "" && itemType == "" && itemSubtype == "" && itemId == "" && itemStart == "") {
503		theUrl = "/" + itemSection + "/"; // base + "/" 
504	}
505    updateContent(data);
506    if (window.history && window.history.pushState) {		
507		history.pushState(data, theTitle, theUrl); // add an item to the history log // http://stackoverflow.com/questions/11932869/ 
508	}
509	// tracking: var tmp_virtualpage = "/" + base + "/" + itemLang + "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "/"; var tmp_title = itemSection + ": " + itemName.replace(/-/g, " "); doTrackPage(tmp_virtualpage,tmp_title);
510}
511
512function setHistory(itemLang,itemSection,itemName,itemType,itemSubtype,itemId,itemStart) {
513	doLog("setHistory(" + itemLang + "," + itemSection + "," + itemName + "," + itemType + "," + itemSubtype + "," + itemId + "," + itemStart + ")");
514	var data = {lang:itemLang,section:itemSection,type:itemType,subtype:itemSubtype,id:itemId,start:itemStart};
515	var theTitle = itemLang + "|" + itemSection + "|" + itemType + "|" + itemSubtype + "|" + itemId + "|" + itemStart;	
516	var theUrl = "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html";
517	// base + "/" + // + itemLang + "/" 
518	// var theUrl = "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html"; // special: itemLang always "en"
519	if (itemName == "" && itemType == "" && itemSubtype == "" && itemId == "" && itemStart == "") {
520		theUrl = "/" + itemSection + "/"; // base + "/" + // + itemLang + "/" 
521	}
522    if (window.history && window.history.pushState) {		
523		history.pushState(data, theTitle, theUrl); // add an item to the history log // http://stackoverflow.com/questions/11932869/ 
524	}
525}
526
527if (window.history && window.history.pushState) {		
528	// revert to a previously saved state
529
530	window.addEventListener('popstate', function(event) {
531		// doLog('popstate fired!');
532		updateContent(event.state);
533	});	
534}
535
536function updateContent(data) {
537    if (data == null) { return; }
538	doShow(data.section,data.type,data.subtype,data.id,1);	
539}
540				
541function doShow(section,type,subtype,id,autoplay) {
542	doLog("doShow(" + section + "," + type + "," + subtype + "," + id + "," + autoplay + ")");
543	/* type = parseInt(type);subtype = parseInt(subtype);id = parseInt(id);autoplay = parseInt(autoplay); */
544	var ausdruck = /^(\w*)?$/;   // \d = digit, \w = word, ? = egal wievielmal vorher (zb. egal wieviel buchstaben)
545	var yOffset = -1 * $(header).height();
546	if (ausdruck.exec(id) && id != "" && id != 0 && id != undefined && id != null) {
547		// prio 1: id
548		var tmp_id = RegExp.$1;
549		doLog("id detected: " + tmp_id);
550		var tmp_type = "";
551		if (ausdruck.exec(type) && type != "" && type != 0 && type != undefined && type != null) {
552			var tmp_type = RegExp.$1;
553			doLog("type detected: " + tmp_type);
554		}
555		// if onepager:
556		if (section != "dates") {
557			if (hist[section]["type"] != tmp_type) {
558				getItems(section,tmp_type,subtype); // only reload items if type changes
559			}
560			getItem(section,tmp_type,subtype,tmp_id,autoplay);
561		}
562		section = section + "_scroll"; // scrollpoint
563		yOffset -= 20;
564	} else {
565		if (ausdruck.exec(subtype) && subtype != "" && subtype != 0 && subtype != undefined && subtype != null) {
566			// prio 2: subtype
567			var tmp_subtype = RegExp.$1;
568			doLog("subtype detected: " + tmp_subtype);
569			if (hist[section]["type"] != type) {
570				getItems(section,type,tmp_subtype); // only reload items if type changes
571			}
572			getItem(section,type,tmp_subtype,id,autoplay);
573			section = section + "_scroll"; // scrollpoint
574			yOffset -= 20;
575		} else {
576			// prio 3: type
577			if (ausdruck.exec(type) && type != "" && type != 0 && type != undefined && type != null) {
578				var tmp_type = RegExp.$1;
579				doLog("type detected: " + tmp_type);
580				$("#" + section + "_holder").slideUp("fast");
581				$("#" + section + "_holder ." + section + "_container").empty();
582				getItems(section,tmp_type,subtype);
583			} else {
584				// prio 4: no type, no subtype, no id -> clear section_holder
585				if (type == "" && subtype == "" && id == "") {
586					doLog("clear of section detected. vars: " + section + "," + type + "," + subtype + "," + id);
587					$("#" + section + "_holder").slideUp("slow", function() {
588						$("#" + section + "_holder ." + section + "_container").empty();
589						$("#" + section + " .itemlist_header").slideUp("fast");
590						getItems(section,"","");
591					});
592				}
593			}
594		}
595	}
596    // yOffset = 0;
597	$.scrollTo("#" + section, 1250, {
598		axis: "y",
599		offset: yOffset,
600		onAfter: function () {
601		}
602	});
603}
604
605// keep tracking of sections content
606var hist = new Array();
607hist["video"] = new Object(); hist["video"]["type"] = ""; hist["video"]["subtype"] = ""; hist["video"]["id"] = ""; hist["video"]["start"] = "";
608hist["photos"] = new Object(); hist["photos"]["type"] = ""; hist["photos"]["subtype"] = ""; hist["photos"]["id"] = ""; hist["photos"]["start"] = "";
609hist["music"] = new Object(); hist["music"]["type"] = ""; hist["music"]["subtype"] = ""; hist["music"]["id"] = ""; hist["music"]["start"] = "";
610hist["news"] = new Object(); hist["news"]["type"] = ""; hist["news"]["subtype"] = ""; hist["news"]["id"] = ""; hist["news"]["start"] = "";
611hist["bio"] = new Object(); hist["bio"]["type"] = ""; hist["bio"]["subtype"] = ""; hist["bio"]["id"] = ""; hist["bio"]["start"] = "";
612hist["products"] = new Object(); hist["products"]["type"] = ""; hist["products"]["subtype"] = ""; hist["products"]["id"] = ""; hist["products"]["start"] = "";
613hist["tracks"] = new Object(); hist["tracks"]["type"] = ""; hist["tracks"]["subtype"] = ""; hist["tracks"]["id"] = ""; hist["tracks"]["start"] = "";
614hist["specials"] = new Object(); hist["specials"]["type"] = ""; hist["specials"]["subtype"] = ""; hist["specials"]["id"] = ""; hist["specials"]["start"] = "";
615hist["remixes"] = new Object(); hist["remixes"]["type"] = ""; hist["remixes"]["subtype"] = ""; hist["remixes"]["id"] = ""; hist["remixes"]["start"] = "";
616hist["gallery"] = new Object(); hist["gallery"]["type"] = ""; hist["gallery"]["subtype"] = ""; hist["gallery"]["id"] = ""; hist["gallery"]["start"] = "";
617
618function saveHistory(section,type,subtype,id) {
619	hist[section]["type"] = type; hist[section]["subtype"] = subtype; hist[section]["id"] = id; hist[section]["start"] = "";
620}
621
622
623// ------------ teaser / carousels ------------ //
624
625function initTabs() {
626	var tablists = document.querySelectorAll('[role=tablist].tablist-auto');
627	for (var i = 0; i < tablists.length; i++) {
628		new TabsAutomatic(tablists[i]);
629	}
630}
631
632function initCarousels() {
633    $('.carousel-holder-size-auto-autoplay .carousel').flickity({ cellAlign:'center', contain:true, cellSelector:'.carousel-cell', setGallerySize:true, autoPlay:3500 });
634	$('.carousel-holder-size-auto .carousel').flickity({ draggable:false, cellAlign:'center', contain:true, cellSelector:'.carousel-cell', setGallerySize:true, adaptiveHeight:true });
635	$('.carousel-holder-size-css .carousel').flickity({ cellAlign:'center', contain:true, cellSelector:'.carousel-cell', setGallerySize:false }); // autoPlay: 5000, 
636    $('.carousel-holder-size-detect-auto .carousel').flickity({ cellAlign:'left', contain:true, cellSelector:'.carousel-cell', setGallerySize:true, autoPlay:5000 });
637	
638    if (isiOS) {
639        /* fix iOS touchmove issue */
640        // https://wpdevdesign.com/fixing-flickitys-issue-with-ios15-safari/
641        (function() {
642            let touchingCarousel = false
643            let startXCoordinate
644
645            document.body.addEventListener('touchstart', e => {
646                if (e.target.closest('.flickity-slider')) {
647                    touchingCarousel = true
648                } else {
649                    touchingCarousel = false
650                    return
651                }
652                startXCoordinate = e.touches[0].pageX
653            })
654
655            document.body.addEventListener('touchmove', e => {
656                if (
657                    !touchingCarousel ||
658                    !e.cancelable ||
659                    Math.abs(e.touches[0].pageX - startXCoordinate) < 8
660                ) return
661                e.preventDefault()
662                e.stopPropagation()
663            }, {
664                passive: false
665            })
666        }())
667        /* prevent resize in flickity if still animating */
668        var resize = Flickity.prototype.resize;
669        Flickity.prototype.resize = function() {
670            if (!this.isAnimating) {
671                resize.call(this);
672            }
673        };
674    }
675    
676    /*
677    $('.carousel').each( function() {
678		var elem = $(this);
679		elem.on('select.flickity', function() {
680			var flkty = elem.data('flickity');
681			elem.find(".carousel-zoom").data("index", flkty.selectedIndex);
682		});
683	});
684	$('.carousel-zoom').click(function(e) {
685		var sources = urldecode($(this).data("sources"));
686		var index = $(this).data("index");
687		eval("$.fancybox.open([" + sources + "], { }, " + index + ")");
688		return false;
689    });
690    $("#teaser-carousel").flickity('playPlayer');
691    */
692
693	var sections = ['products','tracks','specials','remixes'];
694	
695	setTimeout(function() {
696		for (var section of sections) {
697			// doLog("tabindex='-1' for .carousel-cell:not(.is-selected) of " + section);
698			$("#" + section + " .carousel-cell:not(.is-selected)").attr("tabindex","-1");
699			$("#" + section + " .carousel-cell:not(.is-selected) a").attr("tabindex","-1");
700			$("#" + section + " .carousel-cell:not(.is-selected) button").attr("tabindex","-1");
701		}
702	}, 100);
703
704	$(".carousel").on("change.flickity", function(event, index) {
705		var section = $(this).closest('.section').attr("id");
706		if (sections.includes(section)) {
707			// doLog(section + "-carousel > slide changed to " + index);
708			$("#" + section + " .tablist .tab").removeClass("on");
709			$("#" + section + " .tablist .tab").attr("aria-selected",false);
710			$("#" + section + " .tablist .tab").attr("tabindex","-1");
711			$("#" + section + " .item").attr("tabindex","-1");
712			$("#" + section + " .item a").attr("tabindex","-1");
713			$("#" + section + " .item button").attr("tabindex","-1");
714			$("#" + section + " .tablist .tab" + (index + 1)).addClass("on");
715			$("#" + section + " .tablist .tab" + (index + 1)).attr("aria-selected",true);
716			$("#" + section + " .tablist .tab" + (index + 1)).removeAttr("tabindex");
717			$("#" + section + " .item-" + (index + 1)).removeAttr("tabindex");
718			$("#" + section + " .item-" + (index + 1) + " a").removeAttr("tabindex");
719			$("#" + section + " .item-" + (index + 1) + " button").removeAttr("tabindex");
720			var id = $("#" + section + " .item-" + (index + 1)).data("id");
721			var nr = $("#" + section + " .item-" + (index + 1)).data("nr");
722			var name = $("#" + section + " .item-" + (index + 1)).data("name");
723			setHistory(lang,section,name,'','',id,'');
724		}
725	});
726
727}
728
729function setCarouselCell(section,id) {
730    doLog("setCarouselCell(" + section + "," + id + ")");
731	nr = $("#" + section + id).data("nr");
732    $("#" + section + "-carousel").flickity('selectCell', (nr - 1));
733}
734
735
736// ------------- collapse ------------- //
737
738function toggleCollapse(event,target) {   
739    var collapse_item = $(event.target).parents().closest('.item-collapse');
740    var collapse = collapse_item.find('.collapse');
741    var toggle_link = collapse_item.find('.toggle a');
742    if (collapse_item.hasClass('on')) {
743        // close target item
744        collapse_item.removeClass('on');
745        collapse.slideUp("fast", function() {
746            toggle_link.attr("aria-expanded","false");
747            doScroll(collapse_item);
748        });
749    } else {
750        // close already opened item
751        var collapse_items = $(event.target).parents().closest('.items-collapse');
752        var collapse_item_opened = collapse_items.find('.item-collapse.on');
753        var collapse_opened = collapse_item_opened.find('.collapse');
754        var toggle_link_opened = collapse_item_opened.find('.toggle a');
755        collapse_item_opened.removeClass('on');
756        collapse_opened.slideUp("fast", function() {
757            toggle_link_opened.attr("aria-expanded","false");
758        });
759        // open target item
760        collapse_item.addClass('on');
761        collapse.slideDown("slow", function() { 
762            toggle_link.attr("aria-expanded","true");
763            doScroll(collapse_item);
764        });
765    }
766}
767
768// ------------------------ products ------------------------ //
769
770function toggleAlbumplayer(section, id) {
771	if ($("." + section + " #albumplayer" + id).css("display") === "none") {
772		// close other players
773		$("." + section + " .albumplayer").empty();
774		$("." + section + " .albumplayer").css("display","none");
775		$("." + section + " .item li.albumplayer_trigger .title_off").css("display","block");
776		$("." + section + " .item li.albumplayer_trigger .title_on").css("display","none");
777		$("." + section + " .item .imageborder_holder").css("opacity", 1);
778		// load specific player
779		var txt = $("#" + section + " #albumplayer" + id).data("embedcode");
780		$("#" + section + " #albumplayer" + id).html(urldecode(txt));
781		$("#" + section + " #albumplayer" + id).css("display","block");
782		$("#" + section + id + " li.albumplayer_trigger .title_off").css("display","none");
783		$("#" + section + id + " li.albumplayer_trigger .title_on").css("display","block");
784		$("#" + section + id + " .imageborder_holder").css("opacity", 0);
785		doLog("hide: " + "#" + section + id + " .imageborder_holder");
786		doScroll("#" + section + " #albumplayer" + id);
787	} else {
788		$("#" + section + " #albumplayer" + id).empty();
789		$("#" + section + " #albumplayer" + id).css("display","none");
790		$("#" + section + id + " li.albumplayer_trigger .title_off").css("display","block");
791		$("#" + section + id + " li.albumplayer_trigger .title_on").css("display","none");
792		$("#" + section + id + " .imageborder_holder").css("opacity", 1);
793	}
794}
795
796// ------------------------ dates ------------------------ //
797function toggleDates(id) {
798	var new_h, row_display;
799	// get modus (compact, large) usually triggered via @media screen and (max-width:640px) { }
800	if ($("#dates_block" + id + " .dateslist li").first().css("display") === "table") {
801		row_display = "table";
802	} else {
803		row_display = "block";
804	}
805	if ($("#dates_block" + id + " .dateslist li.row-more").css("display") === "none") {
806		// show more rows
807		new_h = $("#dates_block" + id + " .dateslist").innerHeight();
808		$("#dates_block" + id + " .dateslist_holder").css("height", new_h + "px");
809		$("#dates_block" + id + " .dateslist li.row-more").css("display",row_display);
810		new_h = $("#dates_block" + id + " .dateslist").innerHeight();
811		$("#dates_block" + id + " .dateslist_holder").animate({ height: new_h }, "slow", function() {
812			$("#dates_block" + id + " .dateslist_holder").css("height", "auto");
813			$("#dates_block" + id + " .more_dates a.icon-down-open").css("display","none");
814			$("#dates_block" + id + " .more_dates a.icon-up-open").css("display","inline-block");
815			sRefresh();
816  		});	
817	} else {
818		// show less rows
819		$("#dates_block" + id + " .dateslist li.row-more").css("display","none");
820		new_h = $("#dates_block" + id + " .dateslist").innerHeight();
821		$("#dates_block" + id + " .dateslist li.row-more").css("display",row_display);
822		$("#dates_block" + id + " .dateslist_holder").animate({ height: new_h }, "slow", function() {
823			$("#dates_block" + id + " .dateslist li.row-more").css("display","none");
824			$("#dates_block" + id + " .dateslist_holder").css("height", "auto");
825			$("#dates_block" + id + " .more_dates a.icon-down-open").css("display","inline-block");
826			$("#dates_block" + id + " .more_dates a.icon-up-open").css("display","none");
827			$.scrollTo("#dates_block" + id + " .more_dates", 1000, {
828				axis: "y",
829				offset: -220,
830				onAfter: function () {
831				}
832			});
833			sRefresh();
834  		});
835	}
836}
837
838function toggleCalendar(id) {
839	if ($(".calendar_links" + id).css("display") === "none") {
840		$(".calendar_toggle" + id + " .indicator").html('<span class="icon icon-minus"></span>');
841		$(".calendar_toggle" + id).attr("aria-expanded",true);
842		$(".calendar_links" + id).fadeIn("fast", function() { });
843        setTimeout(function(){
844            $(document).click(function(e) {
845                if (!$(e.target).closest(".calendar_links" + id).length) {
846                    // alert('click outside!');
847                    $(".calendar_toggle" + id + " .indicator").html('<span class="icon icon-plus"></span>');
848					$(".calendar_toggle" + id).attr("aria-expanded",false);
849                    $(".calendar_links" + id).fadeOut("fast", function() { });
850                    $(document).unbind("click");
851                }
852            });
853        }, 200);
854	} else {
855		$(".calendar_toggle" + id + " .indicator").html('<span class="icon icon-plus"></span>');
856		$(".calendar_toggle" + id).attr("aria-expanded",false);
857		$(".calendar_links" + id).fadeOut("fast", function() { });
858        $(document).unbind("click");
859	}
860}
861
862
863// ------------------------ audioplayer ------------------------ //
864
865var audioplayerOn = false;
866
867function initAudioplayer() {
868    doLog("initAudioplayer()");
869	var src = $('#audioplayer iframe').data("src");
870	$('#audioplayer iframe').attr("src", src);
871    setTimeout(function() {
872        $('#audioplayer').addClass("on");
873        audioplayerOn = true;
874        /*
875        var waypoint = new Waypoint({
876            element: $('#products h2'),
877            handler: function(direction) {
878                // doLog('Scrolled to #products h2, Direction: ' + direction);
879                if (audioplayerOn == false) {
880                    $('#audioplayer').addClass("on");
881                    audioplayerOn = true;
882                }
883            },
884            offset: 200
885        });
886        */
887	}, 2000);
888}
889
890function toggleAudioplayer() {
891	var toggle_link = $("#audioplayerToggle");
892    if ($('#audioplayer').hasClass("hidden")) {
893        $('#audioplayer').removeClass("hidden");
894		toggle_link.attr("aria-expanded","true");
895		toggle_link.attr("title",urldecode(toggle_link.data("desc-on")));
896    } else {
897        $('#audioplayer').addClass("hidden");
898		toggle_link.attr("aria-expanded","false");
899		toggle_link.attr("title",urldecode(toggle_link.data("desc-off")));
900    }
901}
902
903
904// ------------------------ audio ------------------------ //
905
906function doStop() {
907	doLog("doStop()");
908	var audio = document.getElementById("music_audio");
909 	if (audio) {
910		audio.pause();
911		/*
912		if (oldTrack) {
913			doTrack('Audio','AudioStop',$("#track"+ oldTrack).data("trackname"));
914		}
915		$("#track"+ oldTrack + " .track_progress").css("width", "0%");
916		$("#track"+ oldTrack + " .playback_icon").html("<div class='icon icon-play'></div>");
917		oldTrack = null;
918		playlist_pos = -1;
919		*/
920 	}
921}
922
923function initMusicplayer() {
924	
925	// var music_TRACKS = [ { title: "Trackname 1", src: "https://domain.tld/song1.m4a", duration: "" },{ title: "Trackname 2", src: "https://domain.tld/song2.m4a", duration: "" } ];
926	var music_audio       = document.getElementById('music_audio');
927	var $music_btnPlay    = $('#music_btn-play');
928	var $music_btnPrev    = $('#music_btn-prev');
929	var $music_btnNext    = $('#music_btn-next');
930	var $music_iconPlay   = $('#music_icon-play');
931	var $music_iconPause  = $('#music_icon-pause');
932	var $music_progressIn = $('#music_progress-input');
933	var $music_progressFil= $('#music_progress-fill');
934	var $music_timeCurrent= $('#music_time-current');
935	var $music_timeTotal  = $('#music_time-total');
936	var $music_volumeIn   = $('#music_volume-input');
937	var $music_currentTtl = $('#music_current-title');
938	var $music_tracklist  = $('#music_tracklist');
939	var music_currentIndex = -1;
940	var music_isPlaying    = false;
941
942	// ── Trackliste aufbauen ──
943	function music_isAvailable(t) {
944		return !!(t && t.src && t.src.trim());
945	}
946
947	$.each(music_TRACKS, function (music_i, music_track) {
948		var music_avail = music_isAvailable(music_track);
949		var music_track_title = urldecode(music_track.title);
950		music_track.title = music_track_title.replace(/"/g, "&#34;");
951		var music_ariaLabel = music_avail
952		  ? 'Titel ' + (music_i+1) + ': ' + music_track.title + ' - Play'
953		  : 'Titel ' + (music_i+1) + ': ' + music_track.title + ' - No audio';
954		var music_durationOrBadge = music_avail
955		  ? '<span class="music_track-duration">' + (music_track.duration || '') + '</span>'
956		  : '<span class="music_track-unavailable-badge" aria-hidden="true"><span class="icon icon-volume-off"></span></span>';
957
958		var $music_li = $('<li></li>')
959		  .addClass('music_track-item music_track-item-' + music_i + (music_avail ? '' : ' music_unavailable'))
960		  .attr('role', 'listitem')
961		  .html(
962			'<button ' + (music_avail ? '' : 'disabled') + ' aria-label="' + music_ariaLabel + '" data-index="' + music_i + '">' +
963			  '<span class="music_track-num" aria-hidden="true">' +
964				'<span class="music_track-num-static">' + (music_i+1) + '</span>' +
965				'<span class="music_playing-indicator" aria-hidden="true">' +
966				  '<span class="music_bar"></span><span class="music_bar"></span><span class="music_bar"></span>' +
967				'</span>' +
968			  	'<span class="music_play-indicator" aria-hidden="true"><span class="icon icon-play"></span></span>' +
969			  	'<span class="music_error-indicator" aria-hidden="true"><span class="icon icon-attention"></span></span>' +
970			  '</span>' +
971			  '<span class="music_track-name">' + music_track.title + '</span>' +
972			  music_durationOrBadge +
973			'</button>'
974		  );
975
976		if (music_avail) {
977		  $music_li.find('button').on('click', function () {
978			if (music_currentIndex === music_i && !music_audio.paused) {
979			  music_audio.pause();
980			} else if (music_currentIndex === music_i && music_audio.paused) {
981			  music_audio.play().catch(function () {});
982			} else {
983			  music_loadTrack(music_i, true);
984			}
985		  });
986		}
987		$music_tracklist.append($music_li);
988	});
989
990	// ── Hilfsfunktionen ──
991	function music_formatTime(music_s) {
992		if (!isFinite(music_s)) return '0:00';
993		var music_m   = Math.floor(music_s / 60);
994		var music_sec = String(Math.floor(music_s % 60)).padStart(2, '0');
995		return music_m + ':' + music_sec;
996	}
997
998	function music_loadTrack(music_index, music_autoplay) {
999		if (music_index < 0 || music_index >= music_TRACKS.length) return;
1000
1001		// vorherige aktive Klasse entfernen
1002		$('.music_track-item').removeClass('music_active music_is-playing').find('button').css('--music_track-progress', '');
1003
1004		$("#music_audio").attr("data-index",music_index);
1005		music_currentIndex = music_index;
1006		var music_track    = music_TRACKS[music_index];
1007		music_audio.src    = music_track.src;
1008		music_audio.load();
1009
1010		$music_currentTtl.html(music_track.title);
1011		// document.title = '\u25b6 ' + music_track.title;
1012
1013		$('.music_track-item').eq(music_index).addClass('music_active').find('button').focus();
1014		$music_btnPlay.attr('aria-label', 'Pause: ' + music_track.title);
1015
1016		if (music_autoplay) {
1017		  music_audio.play().catch(function () {});
1018		}
1019	}
1020
1021	function music_togglePlay() {
1022		if (music_currentIndex < 0) { music_loadTrack(0, true); return; }
1023		if (music_audio.paused) {
1024		  music_audio.play().catch(function () {});
1025		} else {
1026		  music_audio.pause();
1027		}
1028	}
1029
1030	function music_nextAvailable(music_from, music_dir) {
1031		var music_i = music_from + music_dir;
1032		while (music_i >= 0 && music_i < music_TRACKS.length) {
1033		  if (music_isAvailable(music_TRACKS[music_i])) return music_i;
1034		  music_i += music_dir;
1035		}
1036		return -1;
1037	}
1038
1039	// ── Audio Events ──
1040	$(music_audio).on('play', function () {
1041		music_isPlaying = true;
1042		$music_iconPlay.hide();
1043		$music_iconPause.show();
1044		$music_btnPlay.attr('aria-label', 'Pause: ' + (music_TRACKS[music_currentIndex] ? music_TRACKS[music_currentIndex].title : ''));
1045		$('.music_track-item').eq(music_currentIndex).addClass('music_is-playing');
1046		$('.music_track-item').eq(music_currentIndex).removeClass('error');
1047	});
1048
1049	$(music_audio).on('pause', function () {
1050		music_isPlaying = false;
1051		$music_iconPlay.show();
1052		$music_iconPause.hide();
1053		$music_btnPlay.attr('aria-label', 'Wiedergabe: ' + (music_TRACKS[music_currentIndex] ? music_TRACKS[music_currentIndex].title : ''));
1054		$('.music_track-item').eq(music_currentIndex).removeClass('music_is-playing');
1055		$('.music_track-item').eq(music_currentIndex).removeClass('error');
1056	});
1057
1058	$(music_audio).on('ended', function () {
1059		var music_next = music_nextAvailable(music_currentIndex, 1);
1060		if (music_next >= 0) music_loadTrack(music_next, true);
1061		else music_isPlaying = false;
1062	});
1063
1064	$(music_audio).on('timeupdate', function () {
1065		if (!music_audio.duration) return;
1066		var music_pct = (music_audio.currentTime / music_audio.duration) * 100;
1067		$music_progressFil.css('width', music_pct + '%');
1068		$music_progressIn.val(music_pct).attr('aria-valuetext', music_formatTime(music_audio.currentTime));
1069		$music_timeCurrent.text(music_formatTime(music_audio.currentTime));
1070		$('.music_track-item').eq(music_currentIndex).find('button').css('--music_track-progress', music_pct + '%');
1071	});
1072
1073	$(music_audio).on('loadedmetadata', function () {
1074		$music_timeTotal.text(music_formatTime(music_audio.duration));
1075		// Dauer in Trackliste aktualisieren, falls leer
1076		// var $music_durEl = $music_tracklist.find('.music_track-duration').eq(music_currentIndex);
1077		// doLog("Loaded metadata @ current index: " + $("#music_audio").attr("data-index"));
1078		var $music_durEl = $(".music_track-item-" + $("#music_audio").attr("data-index") + " .music_track-duration");
1079		if ($music_durEl.length && !music_TRACKS[music_currentIndex].duration) {
1080		  $music_durEl.text(music_formatTime(music_audio.duration));
1081		}
1082	});
1083
1084	$(music_audio).on('error', function () {
1085		var tmp_index = $("#music_audio").attr("data-index");
1086		$music_currentTtl.html('Error loading: ' + (music_TRACKS[tmp_index] ? music_TRACKS[tmp_index].title : ''));
1087		setTimeout(function() {
1088			doLog("Error loading index: " + tmp_index);
1089			$('.music_track-item').eq(tmp_index).addClass('error');
1090			$('.music_track-item').eq(tmp_index).removeClass('music_active');
1091			$('.music_track-item').eq(tmp_index).addClass('music_unavailable');
1092			$('#music_btn-next').focus();
1093		}, 500);
1094		setTimeout(function() {
1095			$('.music_track-item').eq(tmp_index).removeClass('error');
1096		}, 1500);
1097	});
1098
1099	// ── Controls ──
1100	$music_btnPlay.on('click', music_togglePlay);
1101
1102	$music_btnPrev.on('click', function () {
1103		if (music_audio.currentTime > 3) { music_audio.currentTime = 0; return; }
1104		var music_prev = music_nextAvailable(music_currentIndex, -1);
1105		if (music_prev >= 0) music_loadTrack(music_prev, music_isPlaying);
1106	});
1107
1108	$music_btnNext.on('click', function () {
1109		var music_next = music_nextAvailable(music_currentIndex, 1);
1110		if (music_next >= 0) music_loadTrack(music_next, music_isPlaying);
1111	});
1112
1113	// Tastatursteuerung
1114	$(document).on('keydown', function (music_e) {
1115		if ($.inArray(music_e.target.tagName, ['INPUT','TEXTAREA','BUTTON']) >= 0) return;
1116		if (music_e.key === ' ')          { music_e.preventDefault(); music_togglePlay(); }
1117		if (music_e.key === 'ArrowRight') { music_audio.currentTime = Math.min(music_audio.duration, music_audio.currentTime + 5); }
1118		if (music_e.key === 'ArrowLeft')  { music_audio.currentTime = Math.max(0, music_audio.currentTime - 5); }
1119	});
1120
1121	// Progress-Slider
1122	$music_progressIn.on('input', function () {
1123		if (!music_audio.duration) return;
1124		music_audio.currentTime = ($music_progressIn.val() / 100) * music_audio.duration;
1125	});
1126
1127	// Lautstärke
1128	$music_volumeIn.on('input', function () {
1129		music_audio.volume = $music_volumeIn.val();
1130	});
1131
1132}
1133
1134// ------------ bg-video ------------ //
1135
1136function load_bg_video(src,id,loop) {
1137	// doLog("load_bg_video(" + src + "," + id + "," + loop + ")");
1138	var loop_str = "";
1139	var onended_str = "";
1140	if (loop == "Y") {
1141		loop_str = "loop";
1142	} else {
1143		onended_str = "hide_bg_video('bg_video" + id + "');";	
1144	}
1145	var txt = "";
1146	txt += "<video id=\"bg_video" + id + "\" class=\"bg_video bg_video_off\" preload=\"auto\" muted playsinline volume=\"0\" autoplay " + loop_str + " onCanPlay=\"show_bg_video('bg_video" + id + "');\" onended=\"" + onended_str + "\">";
1147	txt += "<source src=\"" + src + "\" type=\"video/mp4\">";
1148	txt += "</video>";
1149	txt += "<div class=\"fg_video fg_video_on\"></div>";
1150	$("#bg_video_holder" + id).html(txt);
1151}
1152
1153function show_bg_video(id) {
1154	if ($("#" + id).hasClass("bg_video_off")) {
1155		if (id == "bg_video-bg-0") {
1156			var vid = document.getElementById(id);
1157			vid.playbackRate = 1;
1158		}
1159		// doLog("show_bg_video(" + id + ")");
1160		$("#" + id).removeClass("bg_video_off");
1161		$("#" + id).addClass("bg_video_on");
1162		$("#" + id).attr("onCanPlay","");
1163	}
1164}
1165
1166function hide_bg_video(id) {
1167	$("#" + id).removeClass("bg_video_on");
1168	$("#" + id).addClass("bg_video_off");
1169}
1170
1171
1172function volume_bg_video(vol) {
1173	var vid = $(".slides .bg_video");
1174	vid.animate({volume: vol}, 1000, 'swing', function() {
1175    	// $(".slides .bg_video").each(this.pause()); // pause video
1176    });
1177}
1178
1179function toggle_bg_video() {
1180	/*
1181	var video = document.getElementById('bg_video_main');
1182	if (bgVideo) {
1183		$(".bg_video_ctrl").removeClass("bg_video_ctrl_on");
1184		if (video) { video.pause(); }
1185		$(".bg_video_holder").hide();
1186		bgVideo = false;
1187	} else {
1188		$(".bg_video_ctrl").addClass("bg_video_ctrl_on");
1189		if (video) { video.play(); }
1190		$(".bg_video_holder").show();
1191		bgVideo = true;
1192	}
1193	*/
1194}
1195
1196
1197// ------------ forms + newsletter ------------ //
1198var newsletterKeyPress = false;
1199function initNewsletter() {
1200	/*
1201    $("#nl_sender_form input").keypress(function(event) {
1202        if (newsletterKeyPress == false) {
1203            newsletterKeyPress = true;
1204            window.dataLayer = window.dataLayer || [];
1205            window.dataLayer.push({
1206                event: "Generic Event",
1207                event_name: "newsletter_soi_start",
1208                newsletter_soi_start: {
1209                    newsletter_selection: nl_addressbooks,
1210                    event_category: "Customer Relations",
1211                    event_action: "Newsletter",
1212                    event_label: "Single Opt-In - Start"
1213                }
1214            });
1215        }
1216    });
1217	*/
1218    // rewrite browser-history for urls like /newsletter/confirm/
1219    var res = /newsletter\/([a-zA-Z]+)/.exec(window.location.href);
1220    if (Array.isArray(res)) {
1221        // doLog("newsletter_path found: " + res[1]);
1222        if (window.history && window.history.replaceState) {
1223            history.replaceState("", window.location.host, window.location.protocol + "//" + window.location.host);
1224        }
1225    }
1226}
1227
1228function validateEmail(email) { 
1229	var exp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
1230	return exp.test(email);
1231}
1232
1233var warnTimeout;
1234
1235function doWarn(id,txt) {
1236	// alert("doWarn(" + id + "," + txt + ")");
1237	$("#"+id).addClass("warning");
1238	$("label[for='"+ id +"']").html("<span class='icon icon-attention' aria-hidden='true'></span> " + txt);
1239	$("label[for='"+ id +"']").addClass("warning");
1240	$("label[for='"+ id +"']").attr("aria-live","assertive");
1241	/*
1242	// make it shake!
1243	$(elem).addClass("animated_manual_animation shake").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function(){
1244    	$(elem).removeClass("animated_manual_animation");
1245		$(elem).removeClass("shake");
1246    });
1247	*/
1248	$("#"+id).disabled = false;
1249	$("#"+id).trigger("focus");
1250	
1251	clearTimeout(warnTimeout);
1252	warnTimeout = setTimeout(function(){ 
1253		resetFormWarnings();
1254	}, 5000);
1255}
1256
1257function resetFormWarnings() {
1258	$("form .text").removeClass("warning");
1259	$("form .text").removeAttr("aria-live");
1260	$("form label").removeClass("warning");
1261	$("form label").removeAttr("aria-live");
1262	$("form label").each(function(index) {
1263		var myText = $(this).attr('data-text');
1264		if (myText !== undefined) {
1265			$(this).html(urldecode(myText));
1266		}
1267	});
1268}
1269
1270function checkInput(id, title, allow_empty) {
1271	title = urldecode(title);
1272	input = $("#" + id);
1273	if (allow_empty === undefined) { allow_empty = false; }
1274	if (allow_empty == false) {
1275		if (input.val() === "" || input.val().length < 2) {
1276			doWarn(id, title + " fehlt.");
1277			return false;
1278		}
1279	}
1280	var zeichen ="<>";
1281	var eingabe = input.val();
1282	var laenge = eingabe.length;
1283	for(i=0; i<laenge;  i++) {
1284	  	badchar = eingabe.charAt(i);
1285	  	if (zeichen.indexOf(badchar)>-1) {
1286			doWarn(id, title + " enthält ungültige Zeichen.");
1287			return false;
1288		}
1289	}
1290	return true;
1291}
1292
1293function checkText(id, title, allow_empty) {
1294	input = $("#" + id);
1295	if (allow_empty === undefined) { allow_empty = false; }
1296	if (allow_empty == false) {
1297		if (input.val() === "" || input.val().length < 24) {
1298			doWarn(id, title + " fehlt.");
1299			return false;
1300		}
1301	}
1302	return true;
1303}
1304
1305function checkCharCount(el) {
1306	var str = $("#" + el).val();	
1307	if ($("#" + el).val().length >= maxChars) {
1308		doWarn(el, "Zu viele Zeichen.");
1309	}
1310}
1311
1312function checkUrl(id, title, allow_empty) {
1313	input = $("#" + id);
1314	if (allow_empty === undefined) { allow_empty = false; }
1315	if (allow_empty == false) {
1316		if (input.val() === "" || input.val().length < 2) {
1317			doWarn(id, title + " fehlt.");
1318			return false;
1319		}
1320	}
1321	var zeichen =";<>";
1322	var eingabe = input.val();
1323	var laenge = eingabe.length;
1324	for(i=0; i<laenge;  i++) {
1325	  	badchar = eingabe.charAt(i);
1326	  	if (zeichen.indexOf(badchar)>-1) {
1327			doWarn(id, title + " enthält ungültige Zeichen.");
1328			return false;
1329		}
1330	}
1331	if (eingabe.indexOf("http") !== 0) {
1332		doWarn(id, title + " muss mit https oder http beginnen.");
1333		return false;
1334	}
1335	return true;
1336}
1337
1338function doFeedback(id,txt) {
1339	$("#"+ id + " .content").removeAttr("aria-live");
1340	$("#"+ id + " .content").removeAttr("role");
1341	setTimeout(function() {
1342		$("#"+ id + " .content").attr("aria-live","assertive");
1343		$("#"+ id + " .content").attr("role","alert");
1344		$("#"+ id + " .content").html(txt);
1345		$("#"+ id + " .content").focus();
1346		$("#" + id).slideDown("slow", function() { });
1347		setTimeout(function() { 
1348			$("#" + id + " a.close").fadeIn("slow");
1349		}, 3000);
1350	}, 250);
1351}
1352
1353function closeFeedback(id) {
1354	$("#" + id + " a.close").fadeOut("fast");
1355	$("#" + id).fadeOut("slow");
1356}
1357
1358function sendnewsletter() {
1359	doLog("sendnewsletter()");	
1360
1361	// check email
1362	if (document.getElementById("nl_email_id")) {
1363		if (!checkInput("nl_email_id", "E-Mail")) { return false; }
1364		if (!validateEmail($("#nl_email_id").val())) {
1365			doWarn("nl_email_id", "Die E-Mail ist ungültig.");
1366			return false; 
1367		}
1368	}
1369
1370	// check firstname
1371	if (document.getElementById("nl_firstname_id")) {
1372		if (!checkInput("nl_firstname_id", "Vorname")) { return false; }
1373	}
1374	
1375	// check nl_country
1376	if (document.getElementById("nl_country_id")) {
1377		if (!checkInput("nl_country_id", "Land")) { return false; }
1378	}
1379	
1380	// send data
1381	var post_data = $("#nl_sender_form").serialize();
1382	
1383	// add pers_lytics_uid
1384	if (window.hasOwnProperty('lio')) {
1385		post_data += "&pers_lytics_uid=" + window.lio._uid;
1386	} else {
1387		post_data += "&pers_lytics_uid=";
1388	}
1389	// doLog("post_data:"); doLog(post_data);
1390    
1391	
1392	$.ajax({
1393		url: "/" + base + "/section_newsletter_sender.php",
1394		data: post_data,
1395		method: "GET",
1396		dataType: "html",
1397		cache: false,
1398		beforeSend: function() {
1399			$("#nl_btn_send_holder").slideUp("fast");
1400			doFeedback("nl_feedback_id","<span class='loading' aria-hidden='true'><span class='spinner' role='status'></span></span> Einen Augenblick bitte...");
1401		},
1402		success: function(data) {
1403			doFeedback("nl_feedback_id",data);
1404			if (data.search(/error/i) == -1 && data.search(/fehler/i) == -1 && data.search(/erreur/i) == -1) {
1405				// feedback contains no errors:
1406				$("#nl_feedback_id a.close").remove();
1407			} else {
1408				$("#nl_btn_send_holder").slideDown("fast");
1409			}
1410		},
1411		error: function(XMLHttpRequest, textStatus, errorThrown) {
1412			alert("Error: " + errorThrown + "(" + XMLHttpRequest.status + ")");
1413			$("#nl_btn_send_holder").slideDown("fast");
1414		},
1415		complete: function() {
1416			//
1417		}
1418	});
1419	
1420	return false;
1421}
1422
1423
1424// ------------ standard functions ------------ //
1425
1426var resized;
1427
1428function initResize() {
1429	doLog("initResize");
1430	$(window).on('resize orientationChanged', function() {
1431		$("#body_id").addClass("resize");
1432		clearTimeout(resized);
1433		resized = setTimeout(onResize, 150);
1434	});
1435}
1436
1437var copyActive = false;
1438
1439function initCopyButtons() {
1440	// doLog("initCopyButtons()"); // for clipboard.js v2.0.6
1441	var clipboard = new ClipboardJS(".copy-button");
1442	clipboard.on('success', function(e) {
1443        if (copyActive == false) {
1444            // console.info('Action:', e.action); console.info('Text:', e.text); console.info('Trigger:', e.trigger);
1445            doTrack('Social', "LinkCopy", urldecode(e.text));
1446            e.clearSelection();
1447            if (lang == "de") {
1448                doMsg("<span class='icon icon-ok'></span> Link kopiert");
1449            } else {
1450                doMsg("<span class='icon icon-ok'></span> Link copied");	
1451            }
1452            copyActive = true;
1453            setTimeout(function() { closeMsg(); copyActive = false; }, 3000);
1454        }
1455	});
1456	var emailclipboard = new ClipboardJS('a.copy-email', {
1457        text: function(trigger) {
1458            return trigger.getAttribute('data-usr') + "@" + trigger.getAttribute('data-dom') + "." + trigger.getAttribute('data-tld');
1459        }
1460    });
1461	emailclipboard.on('success', function(e) {
1462         if (copyActive == false) {
1463            // console.info('emailclipboard Action:', e.action); console.info('emailclipboard Text:', e.text); console.info('Trigger:', e.trigger);
1464            doTrack('Social', "EmailCopy", urldecode(e.text));
1465            e.clearSelection();
1466            if (lang == "de") {
1467                doMsg("<span class='icon icon-ok'></span> E-Mail kopiert");
1468            } else {
1469                doMsg("<span class='icon icon-ok'></span> E-Mail copied");	
1470            }
1471            copyActive = true;
1472            setTimeout(function() { closeMsg(); copyActive = false; }, 3000);
1473         }
1474	});
1475}
1476
1477function doMsg(txt) {
1478	// if ($("#msg .content").html() != "") { doAnim("#msg", "flash"); }
1479	$("#msg .content").html(urldecode(txt));
1480	$("#msg").slideDown('fast', function() {});
1481}
1482
1483function closeMsg() {
1484	if (window.jQuery) {
1485		$("#msg").slideUp("fast", function() { $("#msg .content").empty(); });
1486	} else {
1487		document.getElementById('msg').children[0].innerHTML='';document.getElementById('msg').style.display='none';
1488	}
1489}
1490
1491function setShare(id, url, title) {
1492	var txt = '';
1493	txt += '<div class="share_tools" data-url="' + url + '" data-title="' + title + '">';
1494	txt += '<a class="button share_facebook" href="#" onclick="doShare(event,\'facebook\');return false;" title="Share on facebook"><span class="icon icon-facebook"></span></a>';
1495	// txt += '<a class="button share_facebook_messenger" href="#" onclick="doShare(event,\'facebook_messenger\');" title="Share with Facebook Messenger"><span class="icon icon-facebook-messenger"></span></a>';
1496	txt += '<a class="button share_whatsapp" href="#" onclick="doShare(event,\'whatsapp\');" title="Share with whatsapp"><span class="icon icon-whatsapp"></span></a>';
1497	txt += '<a class="button share_twitter" href="#" onclick="doShare(event,\'twitter\');return false;" title="Tweet"><span class="icon icon-twitter"></span></a>';
1498	txt += '<a class="button share_email" href="#" onclick="doShare(event,\'email\');" title="Share via email"><span class="icon icon icon-mail"></span></a>';
1499	txt += '<a class="button copy-button" data-clipboard-action="copy" data-clipboard-text="' + urldecode(url) + '" href="#" onclick="return false;" title="Copy link"><span class="icon icon-link"></span></a>'; 
1500	txt += '</div>';
1501	$('#' + id).empty().append(txt);
1502	initCopyButtons();
1503}
1504
1505function toggleShare(event) {
1506	$(event.target).closest(".share_tools").toggleClass("on");
1507}
1508
1509function doShare(event, network) {
1510	// doMsg("doShare(" + network + ")");console.log("event:");console.log(event);
1511	var share_el,share_container,url,title,share_window;
1512	// get data-url & data-title from parent div.share_tools
1513	if (event.target.parentNode.className == "share_tools") {
1514		// old safari
1515		share_el = event.target;
1516		share_container = event.target.parentNode;
1517	} else {
1518		share_el = event.target.parentNode;
1519		share_container = event.target.parentNode.parentNode;
1520	}
1521	// console.log("share_container:");console.log(share_container);
1522	url = share_container.dataset.url;
1523	title = share_container.dataset.title;
1524	// console.log("data:");console.log(url);console.log(urldecode(title));doMsg("url: " + urldecode(url) + "<br>title: " + urldecode(title));
1525	switch(network) {
1526		case "facebook":
1527			doTrack('Social', "Facebook", urldecode(url));
1528			share_window = window.open("https://www.facebook.com/sharer/sharer.php?u=" + url,"share_window","width=600,height=450,status=no,location=no,scrollbars=no,resizable=yes");
1529			share_window.focus();
1530			break;
1531		case "twitter":
1532			doTrack('Social', "Twitter", urldecode(url));
1533			title = urldecode(title);
1534			title = encodeURIComponent(title);
1535			$(window).bind("message", function(event) { event = event.originalEvent; if (event.source == share_window && event.data != "__ready__") { doLog("tweet successful"); } });
1536			share_window = window.open("https://twitter.com/intent/tweet?url=" + url + "&text=" + title + "&hashtags=","share_window","width=600,height=500,status=no,location=no,scrollbars=no,resizable=yes");
1537			share_window.focus();
1538			break;
1539		case "email":
1540			doTrack('Social', "Email", urldecode(url));
1541			title = urldecode(title);
1542			title = encodeURIComponent(title);
1543			share_el.href = "mailto:?subject=" + title + "&body=" + url;
1544			break;	
1545		case "whatsapp":
1546			doTrack('Social', "Whatsapp", urldecode(url));
1547			share_el.href = "whatsapp://send?text=" + title + encodeURIComponent(": ") + url;
1548			break;
1549		case "facebook_messenger":
1550			doTrack('Social', "FacebookMessenger", urldecode(url));
1551			share_el.href = "fb-messenger://share?link=" + url;
1552		default:
1553			break;
1554	}
1555}
1556
1557function toggleMenu() {
1558	if ($("#body_id").hasClass("menu_on")) {
1559        $("html").removeClass("menu_on");
1560		$("#body_id").removeClass("menu_on");
1561		$("#menu-toggle").attr("aria-expanded",false);
1562		$("#nav_overlay").attr("aria-hidden",true);
1563		$("#nav_overlay a").attr("tabindex","-1");
1564	} else {
1565		$("html").addClass("menu_on");
1566        $("#body_id").addClass("menu_on");
1567		$("#menu-toggle").attr("aria-expanded",true);
1568		$("#nav_overlay").attr("aria-hidden",false);
1569		$("#header").attr("aria-hidden",false);
1570		$("#nav_overlay a").removeAttr("tabindex");
1571	}
1572}
1573
1574function doScroll(el) {
1575	doLog("doScroll(" + el + ")");
1576	var yOffset = -1 * $(header).outerHeight();
1577	yOffset -= 20;
1578	$.scrollTo(el, 800, {
1579		axis: "y",
1580		offset: yOffset,
1581		onAfter: function () { }
1582	});
1583}
1584
1585function initNav() {
1586	$("#nav_overlay a").attr("tabindex","-1");
1587	$('.header_norm .nav_list a.page_link').on("click", function(){
1588		doShow($(this).data('href'),"",0);
1589		return false;
1590	});
1591	$('.nav_overlay .nav_list a.page_link').on("click", function(){
1592		doShow($(this).data('href'),"",0);
1593		toggleMenu();
1594		return false;
1595	});
1596	var sections = $('section');
1597	var waypoints = sections.waypoint({
1598		handler: function(direction) {
1599			var active_id = this.element.id;
1600			// doLog(active_id + ' hit 40% from top of window');
1601			if (direction === 'up'){ active_id = $("#" + active_id).prev().attr('id'); }
1602			// if (direction === 'down'){ active_id = $("#" + active_id).next().attr('id'); }
1603			$('.nav_list ul li.nav_page').removeClass('on');
1604			$('.nav_list ul li.nav_' + active_id).addClass('on');
1605			// setHash(sectionId); // 2do: if not scrolling because of doShow(), leads to blinks while auto-scrolling (ie, ff)
1606		},
1607		offset: '35%'
1608	});
1609	var waypoint = new Waypoint({
1610		element: $('#header_bottom'),
1611		handler: function(direction) {
1612			// console.log('Scrolled to #header_bottom, Direction: ' + direction);
1613			if (direction === 'up'){
1614				$("#body_id").removeClass("compact");
1615				$(".header-scroll").attr("aria-hidden",true);
1616				$(".header-scroll").attr("tabindex","-1");
1617			}
1618			if (direction === 'down'){
1619				$("#body_id").addClass("compact");
1620				$(".header-scroll").attr("aria-hidden",false);
1621				$(".header-scroll").removeAttr("tabindex");
1622			}
1623		},
1624		offset: -450
1625	});
1626}
1627
1628function initHeader() {
1629	// https://stackoverflow.com/questions/31223341/#answer-31223774
1630	var body = $("#body_id");
1631	var lastScrollTop = 0;
1632	window.addEventListener("scroll", function() {
1633		var st = window.pageYOffset || document.documentElement.scrollTop; // Credits: "https://github.com/qeremy/so/blob/master/so.dom.js#L426"
1634		if (st > lastScrollTop && st > 60){
1635			body.addClass("scrollDown");
1636			// $(".header-scroll").attr("aria-hidden",true);
1637			// $(".header-scroll").attr("tabindex","-1");
1638		} else {
1639			body.removeClass("scrollDown");
1640			// $(".header-scroll").attr("aria-hidden",false);
1641			// $(".header-scroll").removeAttr("tabindex");
1642		}
1643		lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling
1644	}, false);
1645}
1646
1647function initFancybox() {
1648    Fancybox.bind("[data-fancybox]", {
1649        // Your custom options
1650        placeFocusBack: false,
1651        Hash: false,
1652    });
1653	/*
1654    updateFancyboxCarousel();
1655    $(".f-carousel").each(function(index) {
1656        var container = this;
1657        var options = { adaptiveHeight:true, infinite:false, Dots:false, Thumbs:{ type:"classic" } };
1658        this.myCarousel = new Carousel(container, options, { Thumbs });
1659    });
1660	*/
1661}
1662
1663function updateFancyboxCarousel() {
1664    console.log("updateFancyboxCarousel()");
1665    $(".f-carousel__slide").each(function(index) {
1666        var myHeight = $(this).find("img").height(); // console.log("myHeight: " + myHeight);
1667        $(this).css("height",myHeight);
1668    });
1669    /*
1670    setTimeout(function() {
1671        $(".f-carousel").each(function(index) {
1672            if (this.myCarousel) {
1673                console.log(this.myCarousel);
1674                this.myCarousel.reInit();
1675            }
1676        });
1677    }, 100);
1678    */
1679}
1680
1681function doTruncate(identifier, limit) {
1682    switch (lang) {
1683        case "de":
1684            var showText = "Mehr anzeigen";
1685            var hideText = "Weniger anzeigen";
1686            break;
1687        case "fr":
1688            var showText = "Voir Plus";
1689            var hideText = "Voir Moins";
1690            break;
1691        default:
1692            var showText = "Show more";
1693            var hideText = "Show less";
1694            break;
1695    }
1696	if (isNaN(limit)) { limit = 7; }
1697	$(identifier).each( function() {
1698		var myId = "trunc_" + myRandom(100000, 999999);
1699		$(this).attr("id",myId);
1700	});
1701	$(identifier).truncate({
1702		"maxLines": limit,
1703		"truncateString": "&nbsp;&#8230;",
1704		"showText": "<div class='more clearfix'><span class='border title'>
1704" + showText + "</span>&nbsp;<span class='icon icon-down-open'></span></div>",
1705		"hideText": "<div class='more clearfix'><span class='border title'>" + hideText + "</span>&nbsp;<span class='icon icon-up-open'></span></div>",
1706		"animate": true,
1707		"tooltip": false,
1708		"animateOptions": { 'complete': function() {
1709			$(identifier).css("height","auto");
1710			sRefresh();
1711			var myId = $(this).attr("id"); // console.log("myId (after animateOptions complete):" + myId);
1712			$(this).find("a.text_truncate_toggle").attr("aria-controls", myId);
1713			if ($(this).data("status") === "open") {
1714				$(this).data("status","closed");
1715				$(this).find("a.text_truncate_toggle").attr("aria-expanded", false);
1716				$(this).find("a.text_truncate_toggle").attr("aria-controls", myId);
1717				var yOffset = -1 * $(header).height();
1718				yOffset -= 10;
1719				var target = $("#" + myId);
1720				$.scrollTo(target, 1000, {
1721					axis: "y",
1722					offset: yOffset,
1723					duration: 3000,
1724					onAfter: function () {
1725                        try { $('.carousel').flickity('resize'); } catch (e) { }
1726                    }
1727				});
1728			} else {
1729				$(this).data("status","open");
1730				$(this).find("a.text_truncate_toggle").attr("aria-expanded", true);
1731                try { $('.carousel').flickity('resize'); } catch (e) { }
1732			}
1733			
1734			setTimeout(function() {
1735				$(identifier).each( function() {
1736					var myId = $(this).attr("id"); // console.log("myId after timeout: " + myId);
1737					$(this).find("a.text_truncate_toggle").attr("aria-controls", myId);
1738				});
1739			}, 50);
1740			
1741		} }
1742	});
1743	$(identifier).each( function() {
1744		var myId = $(this).attr("id"); // console.log("myId init: " + myId);
1745		$(this).find("a.text_truncate_toggle").attr("aria-controls", myId);
1746	});
1747}
1748
1749function urldecode(str) {
1750	return decodeURIComponent((str+'').replace(/\+/g, ' '));
1751}
1752
1753function doLog(txt) {
1754	node = document.getElementById("log");
1755	if (node) { node.innerHTML = txt + "<br>" + node.innerHTML; }
1756    if (console) { console.log(txt); }
1757}
1758
1759function doTrack(category, action, label) {
1760	if (category != "" && action != "" && typeof dataLayer !== "undefined") {
1761		// umg-tracking
1762        switch(category) {
1763            case "CRM":
1764            case "Video":
1765                dataLayer.push({'event':'GAEvent', 'attributes': {'eventCategory': '' + category + '', 'eventAction': '' + action +'', 'eventLabel': '' + label + '' }});
1766                break;
1767            case "Social":
1768                dataLayer.push({'event': 'Generic Event', 'event_name': 'share_start', 'share_start' : { 'social_network': '' + action + '', 'event_category': 'Social', 'event_action': 'Share - ' + action + '', 'event_label': '' + label + ''}});
1769                break;
1770            case "Audio":
1771                dataLayer.push({'event': "Generic Event", 'event_name': "audio_play", 'audio_play': { 'artist_name': '' + artist + '', 'audio_name': '' + label + '', 'event_category': "Audio", 'event_action': '' + action + '', 'event_label': '' + label + '' }});
1772                break;
1773            default:
1774                break;    
1775        }
1776		// analytics.js
1777		// ga('send', 'event', category, action, label);
1778		// ga.js:
1779		// _gaq.push(['_trackEvent', category, action, label]);	
1780	}
1781	doLog("doTrack(" + category + " | " + action + " | " + label + ")");
1782}
1783
1784function initSvg() {
1785	$('img.svg').each(function(){
1786		var $img = $(this); var imgID = $img.attr('id'); var imgClass = $img.attr('class'); var imgURL = $img.attr('src');
1787		$.get(imgURL, function(data) {
1788			var $svg = $(data).find('svg');
1789			if (typeof imgID !== 'undefined') { $svg = $svg.attr('id', imgID); }
1790			if (typeof imgClass !== 'undefined') { $svg = $svg.attr('class', imgClass+' replaced-svg'); }
1791			$svg = $svg.removeAttr('xmlns:a'); $img.replaceWith($svg);
1792		}, 'xml');
1793	});
1794}
1795
1796function getCacheControl() {
1797	var date = new Date();
1798	var year = date.getUTCFullYear();
1799	var month = date.getUTCMonth(); 
1800	month++; // (from 0-11)
1801	if (month < 10) { month = "0" + month; }
1802	var day = date.getUTCDate();
1803	if (day < 10) { day = "0" + day; }
1804	var hour = date.getUTCHours();
1805	if (hour < 10) { hour = "0" + hour; }
1806	var minutes = date.getUTCMinutes();
1807	switch(true) { case minutes>45:minutes="45";break; case minutes>30:minutes="30";break; case minutes>15:minutes="15";break; default:minutes="00";break; }
1808	var c = year + month + day + "-" + hour + minutes;
1809	return c;
1810}
1811
1812function inIframe() {
1813    try {
1814        return window.self !== window.top;
1815    } catch (e) {
1816        return true;
1817    }
1818}
1819
1820function checkLinks() {
1821    $('a[href^="http"]').not('a[href*="' + location.hostname + '"]').attr({target: "_blank", rel: "noopener"});
1822}
1823
1824function winopen(url,name,w,h) {
1825	var w_shift = Number((screen.width/2)-(w/2));
1826	var h_shift = Number((screen.height/2)-(h/2));
1827	var newWin = window.open(url, name, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+w+', height='+h+', left='+w_shift+', top='+h_shift);
1828	newWin.focus();
1829}
1830
1831function capitalizeFirstLetter(string) {
1832    return string.charAt(0).toUpperCase() + string.slice(1);
1833}
1834
1835function getCookieValue(a) { // thx 2 mac: http://stackoverflow.com/questions/5639346/#answer-25490531
1836    var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)');
1837    return b ? b.pop() : '';
1838}
1839
1840function getRequestVar(name){
1841	if (name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)) { return decodeURIComponent(name[1]); }
1842}
1843
1844function kill(id) {
1845	element = document.getElementById(id);
1846 	if (element) {
1847  		var parent = element.parentNode;
1848  		if (parent) {
1849			parent.removeChild(element);
1850		}
1851 	}
1852 	return false;
1853}
1854
1855// thx Jonas Raoni Soares Silva, http://jsfromhell.com/array/shuffle [rev. #1] // usage: var a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; alert('shuffle(a): ' + shuffle(a));
1856function shuffle(v) {
1857    for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);
1858    return v;
1859};
1860
1861function myRandom(a, b) {
1862	if (a > b) { return(-1); }
1863	if (a === b) { return(a); }
1864	return a + parseInt(Math.random() * ( b - a+1 ));
1865}
1866
1867// peace out

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.