PageSourceSearch

https://www.gregorian.de/2/js/functions.js?v=7210362

js gregorian.de collected 2026-10-02 08:02:42 UTC 58,684 bytes, 1,608 lines download raw bytes

1// gregorian | 2 | functions.js
2
3// ------------ scroll to 0 ------------ /
4window.scrollTo(0,0);
5// window.onbeforeunload = function(){ window.scrollTo(0,0); };
6var cachecontrol = getCacheControl();
7
8function doCtrl() {
9	// hi ;)
10}
11
12function onPageReady() {
13	doLog("onPageReady");
14	getConf();
15	initAnims();
16	doTruncate('.text_truncate', 8);
17    initCarousels();
18	initSvg();
19	if (main == "index") {
20		initNav();
21        hidePreloader();
22        initMasonry();
23	}
24	sInit();
25    checkLinks();
26    initCookieConsent();
27	onResize();
28	initResize();
29	sRefresh();
30    lazySizes.init();
31}
32
33function onPageLoaded() {
34	doLog("onPageLoaded");
35	if (main === "index") {
36        setTimeout(function() { initYouTube(); }, 5000);
37        initFancybox();
38		initMusicplayer();
39	}
40	sRefresh(); setTimeout(function() { sRefresh(); }, 3000); // includes: initCopyButtons();
41}
42
43function hidePreloader() {
44	$('#loading-animation').removeClass("fadeIn");
45	$('#loading-animation').addClass("animated_manual_animation fadeOut");
46	$('#preloader').delay(850).fadeOut(800);
47    
48	setTimeout(function() {
49		$('.header_norm .social .animated_manual').each( function() {
50			var elem = $(this);
51			if ( !elem.hasClass('visible') ) {
52				var animationDelay = elem.data('animation-delay');
53				var animation = elem.data('animation');
54				if ( animationDelay ) {
55					setTimeout(function(){
56						elem.addClass( animation + " animated_manual_animation visible" );
57					}, animationDelay);
58				} else {
59					elem.addClass( animation + " animated_manual_animation visible" );
60				}
61			}
62		});
63	}, 2000);
64    
65	$('#teaser .animated_manual').each( function() {
66		var elem = $(this);
67		if ( !elem.hasClass('visible') ) {
68			var animationDelay = elem.data('animation-delay');
69			var animation = elem.data('animation');
70			if ( animationDelay ) {
71				setTimeout(function(){
72					elem.addClass( animation + " animated_manual_animation visible" );
73				}, animationDelay);
74			} else {
75				elem.addClass( animation + " animated_manual_animation visible" );
76			}
77		}
78	});
79}
80
81function skipIntro() {
82	doScroll('#products');
83	volume_bg_video(0);
84}
85
86function onResize() {
87	sRefresh();
88}
89
90// ------------ effects ------------ //
91
92function initAnims() {
93	$('.animated').appear();
94	$('.animated').on('appear', function() {
95		var elem = $(this);
96		var animation = elem.data('animation');
97		if (!elem.hasClass('visible')) {
98			var animationDelay = elem.data('animation-delay');
99			if (animationDelay) {
100				setTimeout(function() {
101					elem.addClass(animation + " visible");
102				}, animationDelay);
103			} else {
104				elem.addClass(animation + " visible");
105			}
106		}
107	});
108	$(window).on("load", function() {
109		$('.onstart').each(function() {
110			var elem = $(this);
111			if (!elem.hasClass('visible')) {
112				var animationDelay = elem.data('animation-delay');
113				var animation = elem.data('animation');
114				if (animationDelay) {
115					setTimeout(function() {
116						elem.addClass(animation + " visible");
117					}, animationDelay);
118				} else {
119					elem.addClass(animation + " visible");
120				}
121			}
122		});
123	});
124}
125
126function initAnimsManual(target) {
127	$(target).appear();
128	$(target).on('appear', function() {
129		var elem = $(this);
130		var animation = elem.data('animation');
131		if (!elem.hasClass('visible')) {
132			var animationDelay = elem.data('animation-delay');
133			if (animationDelay) {
134				setTimeout(function(){
135					elem.addClass(animation + " visible");
136				}, animationDelay);
137			} else {
138				elem.addClass(animation + " visible");
139			}
140		}
141	});
142}
143
144function doAnim(elem, effect, remove) {
145	if (remove === false) { 
146		$(elem).addClass("animated_manual_animation " + effect).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function() {});
147	} else {
148		$(elem).addClass("animated_manual_animation " + effect).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function() {
149			$(elem).removeClass("animated_manual_animation");
150			$(elem).removeClass(effect);
151		});
152		$(elem).removeClass('animated_manual');
153	}
154}
155
156// ------------ inits ------------ /
157// https://stackoverflow.com/questions/9038625/#answer-9039885, https://stackoverflow.com/questions/7944460/
158var isiOS = ['iPad Simulator','iPhone Simulator','iPod Simulator','iPad','iPhone','iPod'].includes(navigator.platform)||(navigator.userAgent.includes("Mac")&&"ontouchend"in document);
159var isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 && navigator.userAgent && navigator.userAgent.indexOf('CriOS') == -1 && navigator.userAgent.indexOf('FxiOS') == -1;
160var isSafariMac = false;
161
162function getConf() {
163	if (device == "") {
164		// http://stackoverflow.com/questions/3514784/
165		var ua = navigator.userAgent.toLowerCase(); doLog("ua: " + ua);
166        var vendor = navigator.vendor;
166 doLog("vendor: " + vendor);
167		if (ua.match(/webos/i)) { device = "webos"; }
168		if (ua.match(/opera mini/i)) { device = "opera mini"; }		
169		if (ua.match(/mobile/i)) { device = "mobile"; }
170		if (ua.match(/ipad/i)) { device = "ipad"; }
171		if (ua.match(/ipod|iphone/i)) { device = "iphone"; }
172		if (ua.match(/blackberry/i)) { device = "blackberry"; }
173		if (ua.match(/android/i)) { device = "android"; }
174		if (ua.match(/kindle/i)) { device = "kindle"; }
175		if (ua.match(/windows phone/i)) { device = "windows phone"; }
176		if (ua.match(/iemobile/i)) { device = "iemobile"; }
177		if (ua.match(/tablet/i)) { device = "tablet"; }
178    }
179    if (isSafari && isiOS) {
180        isSafariMac = false; doLog("safari on ios");
181    } else {
182        if (isSafari) { isSafariMac = true; doLog("safari on mac"); }
183    }
184	doLog("getConf() -> device: " + device);
185	if (device === "ipad" || device === "tablet") { $("#viewport_id").attr("content", "width=device-width, initial-scale=1"); } // set viewport
186	if (device !== "") {
187		$("#body_id").removeClass("desktop").addClass("device"); // set body-class, default: desktop
188	}
189	if (isiOS) {
190		$("#body_id").addClass("iOS");
191	}
192}
193
194function sInit() {
195	if (device === "" && main == "index") { s = skrollr.init({ forceHeight:false }); } 
196}
197
198function sRefresh() {
199	if (device === "" && main == "index") { window.setTimeout(function() { s.refresh(); } , 1000); }
200	Waypoint.refreshAll();
201	initCopyButtons();
202}
203
204
205// ------------------------ gallery ------------------------ //
206var $grid;
207
208var masonryOptions = {
209    itemSelector: '.grid-item',
210    // columnWidth: 80,
211    gutter: 30
212};
213
214function initMasonry() {
215	$grid = $('.grid').masonry(masonryOptions);
216}
217
218function destroyMasonry() {
219	$grid.masonry('destroy');
220}
221
222
223// ------------ load section-content ------------ //
224function getItems(section,type,subtype) {
225	doLog("getItems('" + section + "," + type + "," + subtype + "')");
226	saveHistory(section,type,subtype,"");
227	$.ajax({
228		url: "/" + base + "/section_" + section + "_get_items.php",
229		data: "section=" + section + "&type=" + type + "&subtype=" + subtype + "&lang=" + lang + "&device=" + device + "&country=" + country,
230		method: "GET",
231		dataType: "html",
232		cache: false,
233		beforeSend: function() {
234			$("#" + section + " ul.sub_nav li").removeClass("on");
235			$("#" + section + "_items ul.itemlist").empty();
236			$("#" + section + "_items .more").html('<div class="loading"><div class="icon icon-spin5 animate-spin"></div></div>');
237            if (section == "gallery") {
238                destroyMasonry();
239                $('.grid').empty();
240            }
241		},
242		success: function(data) {
243            $("#" + section + "_items ul.itemlist").attr("class","itemlist type-" + type + " clearfix"); // gregorian special
244			$("#" + section + " ul.sub_nav li.type" + type).addClass("on");
245            if (section == "gallery") {
246                initMasonry();
247                var $content = $(data);
248                $grid.append($content).masonry('appended', $content);
249                setTimeout(function(){ $grid.masonry(); }, 100);
250            } else {
251                $("#" + section + "_items ul.itemlist").append(data);
252            }
253		},
254		error: function(XMLHttpRequest, textStatus, errorThrown) {
255			// alert("Error:" + errorThrown + "(" + XMLHttpRequest.status + ")");
256		},
257		complete: function() {
258			sRefresh();
259		}
260	});
261}
262
263function getMoreItems(section,start,limit,type,subtype,id,modus) {
264	doLog("getMoreItems('" + section + "," + start + "," + limit + "," + type + "," + subtype + "," + id + "," + modus + "')");
265	if (start < 0) { start = 0; }
266	$.ajax({
267		url: "/" + base + "/section_" + section + "_get_items.php",
268		data: "section=" + section + "&start=" + start + "&limit=" + limit + "&type=" + type + "&subtype=" + subtype + "&id=" + id + "&lang=" + lang + "&device=" + device + "&country=" + country,
269		method: "GET",
270		dataType: "html",
271		cache: false,
272		beforeSend: function() {
273			$("#" + section + "_items .more").html('<div class="loading"><div class="icon icon-spin5 animate-spin"></div></div>');
274		},
275		success: function(data) {
276            $("#" + section + "_items ul.itemlist").attr("class","itemlist type-" + type + " clearfix"); // gregorian special
277			if (modus === "clear") {
278				$("#" + section + "_items ul.itemlist").empty().append(data);
279			} else {
280                if (section == "gallery") {
281                    var $content = $(data);
282                    $grid.append($content).masonry('appended', $content);
283                    setTimeout(function(){ $grid.masonry(); }, 100);
284                } else {
285                    $("#" + section + "_items ul.itemlist").append(data);
286                }
287			}
288		},
289		error: function(XMLHttpRequest, textStatus, errorThrown) {
290			// alert("Error:" + errorThrown + "(" + XMLHttpRequest.status + ")");
291		},
292		complete: function() {
293			sRefresh();
294		}
295	});
296}
297
298function getItem(section,type,subtype,id,autoplay) {
299	doLog("getItem(" + section + "," + type + "," + subtype + "," + id + "," + autoplay + ")");
300	saveHistory(section,type,subtype,id);
301	var ausdruck = /^(\d*)?$/;   // \d = digit, \w = word, ? = egal wievielmal vorher (zb. egal wieviel buchstaben)
302	if (ausdruck.exec(id)) {
303		// alert("valid request ->\n id:" + RegExp.$1);
304		var id = RegExp.$1;
305		var feedback_id = "#" + section + "_container";
306		$.ajax({
307			url: "/" + base + "/section_" + section + "_get_item.php",
308			data: "type=" + type + "&subtype=" + subtype + "&id=" + id + "&autoplay=" + autoplay + "&lang=" + lang + "&device=" + device + "&country=" + country,
309			method: "GET",
310			dataType: "html",
311			cache: false,
312			beforeSend: function() {
313				$("#" + section + " ul.sub_nav li").removeClass("on");
314                $("#" + section + "_holder").removeClass(function (index, className) { return (className.match (/(^|\s)type-\S+/g) || []).join(' '); }); // https://stackoverflow.com/questions/2644299/
315                $("#" + section + "_holder").addClass("type-" + type);
316				$("#" + section + "_holder").slideDown(1000);
317				$("#" + section + "_title").empty().append("Loading...");
318				$(feedback_id).html('<div class="loading"><div class="icon icon-spin5 animate-spin"></div></div>');
319			},
320			success: function(data) {
321				$("#" + section + " ul.sub_nav li.type" + type).addClass("on");
322				$(feedback_id).empty().append(data);
323                initSvg(feedback_id);
324			},
325			error: function(XMLHttpRequest, textStatus, errorThrown) {
326				// alert("Error:" + errorThrown + "(" + XMLHttpRequest.status + ")");
327			},
328			complete: function() {
329				sRefresh();
330			}
331		});
332	} else {
333		alert("invalid request");
334	}
335}
336
337function setItem(section, id, txt) {
338	// doLog("setItem(" + section + "," + id + "," + txt + ")");
339	if (section === "video") {
340		ytFirstStart = false;
341		$("#video_title").empty().append(urldecode(txt));
342	}
343	$("." + section + "_items ul li").removeClass("on");
344	$("." + section + "_items ul li.item" + id).addClass("on");
345	sRefresh();
346}
347
348// ------------------------ history ------------------------ //
349function getContent(itemLang,itemSection,itemName,itemType,itemSubtype,itemId,itemStart) {
350	// alert("getContent(" + itemLang + "," + itemSection + "," + itemName + "," + itemType + "," + itemSubtype + "," + itemId + "," + itemStart + ")");
351	doStop();
352	var data = {lang:itemLang,section:itemSection,type:itemType,subtype:itemSubtype,id:itemId,start:itemStart};
353	var theTitle = itemLang + "|" + itemSection + "|" + itemType + "|" + itemSubtype + "|" + itemId + "|" + itemStart;	
354	var theUrl = "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html";
355	// base + "/" + // + itemLang + "/"
356	// var theUrl = "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html"; // special: itemLang always "en"
357	if (itemName == "" && itemType == "" && itemSubtype == "" && itemId == "" && itemStart == "") {
358		theUrl = "/" + itemSection + "/"; // base + "/" + itemLang + "/" 
359	}
360    updateContent(data);
361    if (window.history && window.history.pushState) {		
362		history.pushState(data, theTitle, theUrl); // add an item to the history log // http://stackoverflow.com/questions/11932869/ 
363	}
364	// tracking: var tmp_virtualpage = "/" + base + "/" + itemLang + "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "/"; var tmp_title = itemSection + ": " + itemName.replace(/-/g, " "); doTrackPage(tmp_virtualpage,tmp_title);
365}
366
367function setHistory(itemLang,itemSection,itemName,itemType,itemSubtype,itemId,itemStart) {
368	doLog("setHistory(" + itemLang + "," + itemSection + "," + itemName + "," + itemType + "," + itemSubtype + "," + itemId + "," + itemStart + ")");
369	var data = {lang:itemLang,section:itemSection,type:itemType,subtype:itemSubtype,id:itemId,start:itemStart};
370	var theTitle = itemLang + "|" + itemSection + "|" + itemType + "|" + itemSubtype + "|" + itemId + "|" + itemStart;	
371	var theUrl = "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html";
372	// base + "/" + // + itemLang + "/" 
373	// var theUrl = "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html"; // special: itemLang always "en"
374	if (itemName == "" && itemType == "" && itemSubtype == "" && itemId == "" && itemStart == "") {
375		theUrl = "/" + itemSection + "/"; // base + "/" + // + itemLang + "/" 
376	}
377    if (window.history && window.history.pushState) {		
378		history.pushState(data, theTitle, theUrl); // add an item to the history log // http://stackoverflow.com/questions/11932869/ 
379	}
380}
381
382if (window.history && window.history.pushState) {		
383	// revert to a previously saved state
384	window.addEventListener('popstate', function(event) {
385		// doLog('popstate fired!');
386		updateContent(event.state);
387	});	
388}
389
390function updateContent(data) {
391    if (data == null) { return; }
392	doShow(data.section,data.type,data.subtype,data.id,1);	
393}
394				
395function doShow(section,type,subtype,id,autoplay) {
396	doLog("doShow(" + section + "," + type + "," + subtype + "," + id + "," + autoplay + ")");
397	/* type = parseInt(type);subtype = parseInt(subtype);id = parseInt(id);autoplay = parseInt(autoplay); */
398	var ausdruck = /^(\w*)?$/;   // \d = digit, \w = word, ? = egal wievielmal vorher (zb. egal wieviel buchstaben)
399	var yOffset = -1 * $(".header_norm").height();
400	if (ausdruck.exec(id) && id != "" && id != 0 && id != undefined && id != null) {
401		// prio 1: id
402		var tmp_id = RegExp.$1;
403		doLog("id detected: " + tmp_id);
404		var tmp_type = "";
405		if (ausdruck.exec(type) && type != "" && type != 0 && type != undefined && type != null) {
406			var tmp_type = RegExp.$1;
407			doLog("type detected: " + tmp_type);
408		}
409		// if onepager:
410		if (section != "dates") {
411			if (hist[section]["type"] != tmp_type) {
412				getItems(section,tmp_type,subtype); // only reload items if type changes
413			}
414			getItem(section,tmp_type,subtype,tmp_id,autoplay);
415		}
416		section = section + "_scroll"; // scrollpoint
417		yOffset -= 20;
418	} else {
419		if (ausdruck.exec(subtype) && subtype != "" && subtype != 0 && subtype != undefined && subtype != null) {
420			// prio 2: subtype
421			var tmp_subtype = RegExp.$1;
422			doLog("subtype detected: " + tmp_subtype);
423			if (hist[section]["type"] != type) {
424				getItems(section,type,tmp_subtype); // only reload items if type changes
425			}
426			getItem(section,type,tmp_subtype,id,autoplay);
427			section = section + "_scroll"; // scrollpoint
428			yOffset -= 20;
429		} else {
430			// prio 3: type
431			if (ausdruck.exec(type) && type != "" && type != 0 && type != undefined && type != null) {
432				var tmp_type = RegExp.$1;
433				doLog("type detected: " + tmp_type);
434				$("#" + section + "_holder").slideUp("fast");
435				$("#" + section + "_holder ." + section + "_container").empty();
436				getItems(section,tmp_type,subtype);
437			} else {
438				// prio 4: no type, no subtype, no id -> clear section_holder
439				if (type == "" && subtype == "" && id == "") {
440					doLog("clear of section detected. vars: " + section + "," + type + "," + subtype + "," + id);
441					$("#" + section + "_holder").slideUp("slow", function() {
442						$("#" + section + "_holder ." + section + "_container").empty();
443						$("#" + section + " .itemlist_header").slideUp("fast");
444						getItems(section,"","");
445					});
446				}
447			}
448		}
449	}
450	$.scrollTo("#" + section, 1250, {
451		axis: "y",
452		offset: yOffset,
453		onAfter: function () {
454		}
455	});
456}
457
458// keep tracking of sections content
459var hist = new Array();
460hist["video"] = new Object(); hist["video"]["type"] = ""; hist["video"]["subtype"] = ""; hist["video"]["id"] = ""; hist["video"]["start"] = "";
461hist["photos"] = new Object(); hist["photos"]["type"] = ""; hist["photos"]["subtype"] = ""; hist["photos"]["id"] = ""; hist["photos"]["start"] = "";
462hist["music"] = new Object(); hist["music"]["type"] = ""; hist["music"]["subtype"] = ""; hist["music"]["id"] = ""; hist["music"]["start"] = "";
463hist["news"] = new Object(); hist["news"]["type"] = ""; hist["news"]["subtype"] = ""; hist["news"]["id"] = ""; hist["news"]["start"] = "";
464hist["bio"] = new Object(); hist["bio"]["type"] = ""; hist["bio"]["subtype"] = ""; hist["bio"]["id"] = ""; hist["bio"]["start"] = "";
465hist["products"] = new Object(); hist["products"]["type"] = ""; hist["products"]["subtype"] = ""; hist["products"]["id"] = ""; hist["products"]["start"] = "";
466hist["tracks"] = new Object(); hist["tracks"]["type"] = ""; hist["tracks"]["subtype"] = ""; hist["tracks"]["id"] = ""; hist["tracks"]["start"] = "";
467hist["gallery"] = new Object(); hist["gallery"]["type"] = ""; hist["gallery"]["subtype"] = ""; hist["gallery"]["id"] = ""; hist["gallery"]["start"] = "";
468
469function saveHistory(section,type,subtype,id) {
470	hist[section]["type"] = type; hist[section]["subtype"] = subtype; hist[section]["id"] = id; hist[section]["start"] = "";
471}
472
473// ------------ teaser / carousels ------------ //
474function initCarousels() {
475    $('.carousel-holder-size-auto-autoplay .carousel').flickity({ cellAlign:'left', contain:true, cellSelector:'.carousel-cell', setGallerySize:true, autoPlay:3500 });
476	$('.carousel-holder-size-auto .carousel').flickity({ cellAlign:'left', contain:true, cellSelector:'.carousel-cell', setGallerySize:true, adaptiveHeight:true });
477	$('.carousel-holder-size-css .carousel').flickity({ cellAlign:'left', contain:true, cellSelector:'.carousel-cell', setGallerySize:false }); // autoPlay: 5000, 
478    /*
479    $('.carousel').each( function() {
480		var elem = $(this);
481		elem.on('select.flickity', function() {
482			var flkty = elem.data('flickity');
483			elem.find(".carousel-zoom").data("index", flkty.selectedIndex);
484		});
485	});
486	$('.carousel-zoom').click(function(e) {
487		var sources = urldecode($(this).data("sources"));
488		var index = $(this).data("index");
489		eval("$.fancybox.open([" + sources + "], { }, " + index + ")");
490		return false;
491    });
492    $("#teaser-carousel").flickity('playPlayer');
493    */
494    
495    $("#products-carousel").on('change.flickity', function(event, index) {
496        doLog('products-carousel > slide changed to ' + index);
497        $("#products .sub_nav li").removeClass("on");
498        $("#products .sub_nav li.thumb" + (index + 1)).addClass("on");       
499        id = $("#products .item-" + (index + 1)).data("id");
500        nr = $("#products .item-" + (index + 1)).data("nr");
501        var name = $("#products .item-" + (index + 1)).data("name");
502        setHistory(lang,'products',name,'','',id,'');
503    });
504    
505    $("#tracks-carousel").on('change.flickity', function(event, index) {
506        doLog('tracks-carousel > slide changed to ' + index);
507        $("#tracks .sub_nav li").removeClass("on");
508        $("#tracks .sub_nav li.thumb" + (index + 1)).addClass("on");       
509        id = $("#tracks .item-" + (index + 1)).data("id");
510        nr = $("#tracks .item-" + (index + 1)).data("nr");
511        var name = $("#tracks .item-" + (index + 1)).data("name");
512        setHistory(lang,'tracks',name,'','',id,'');
513    });
514    
515	$('#video-carousel').on('change.flickity', function(event, index) {
516        doLog('video-carousel > slide changed to ' + index);
517        $("#video .sub_nav li").removeClass("on");
518        $("#video .sub_nav li.thumb" + (index + 1)).addClass("on");       
519        id = $("#video .item-" + (index + 1)).data("id");
520        nr = $("#video .item-" + (index + 1)).data("nr");
521        var name = $("#video .item-" + (index + 1)).data("name");
522        setHistory(lang,'video',name,'','',id,'');
523        // video special
524        $("#video-carousel .carousel-cell").removeClass("video-on");
525        $("#video-carousel .video-player").removeClass("on");
526        setTimeout(function() {
527            $("#video-carousel .video-player").html("");
528        }, 1000);
529    });
530}
531
532function setCarouselCell(section,id) {
533    doLog("setCarouselCell(" + section + "," + id + ")");
534	nr = $("#" + section + id).data("nr");
535    $("#" + section + "-carousel").flickity('selectCell', (nr - 1));
536}
537
538function getCarouselVideo(section,feedback_id,id) {
539	// alert("getCarouselVideo(" + section + "," + feedback_id + ","+ id + ")");
540	$.ajax({
541		url: "/" + base + "/section_get_carousel_video.php",
542		data: "section=" + section + "&id=" + id + "&country=" + country + "&device=" + device,
543		method: "GET",
544		dataType: "html",
545		cache: false,
546		beforeSend: function() {
547			$(feedback_id).html('<div class="loading"><div class="icon icon-spin5 animate-spin"></div></div>');
548		},
549		success: function(data) {
550			$(feedback_id).empty().append(data);
551		},
552		error: function(XMLHttpRequest, textStatus, errorThrown) {
553			// alert("Error:" + errorThrown + "(" + XMLHttpRequest.status + ")");
554		},
555		complete: function() {
556			sRefresh(); // alert("complete");
557		}
558	});
559}
560
561
562// ------------------------ youtube ------------------------ //
563function initYouTube() {
564	var tag = document.createElement('script');
565	tag.src = "https://www.youtube.com/iframe_api";
566	var firstScriptTag = document.getElementsByTagName('script')[0];
567	firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
568}
569var ytApiKey = "AIzaSyBiYOXVYHnSaIHec43Ixj-GaIrF84UR9bQ";
570function onYTPlayerRendered(iframe_id) {
571	if (typeof(YT) != "undefined") {
572		doLog("video: yt-api ready");
573		if (iframe_id == "undefined" || iframe_id == ""|| iframe_id == null) {
574			iframe_id = "videoiframe";
575		}
576		if (document.getElementById(iframe_id)) {
577			doLog("video: rendered");
578			var tmp_player = new YT.Player(iframe_id, { events: { 'onReady': onYTPlayerReady, 'onStateChange': onYTPlayerStateChange } });
579		}
580	} else {
581		doLog("video: yt-api not ready");
582	}
583}
584function onYTPlayerReady(event) {
585	var tmp_id = "";
586	var obj = event.target;	
587	for (var key in obj) {
588		if (Object.prototype.hasOwnProperty.call(obj, key)) { // http://stackoverflow.com/questions/7306669/
589			var val = obj[key];
590			if (val.nodeName === "IFRAME") {
591				tmp_id = urldecode(val.id); // eg.: "video_playlist_PLpEG-NdxDo_uucxo-LKxaXbuZfCScOSlX";
592				doLog("video: ready, id: " + tmp_id);
593				if (tmp_id.indexOf("playlist") !== -1) {
594					var reg = /video_playlist_(.*)/;
595					var res = reg.exec(tmp_id);
596					if (Array.isArray(res)) {
597						var ytPlaylist = res[1];
598						doLog("video: playlist detected: " + ytPlaylist); 
599						getYTPlaylist(ytPlaylist,tmp_id);
600					}
601				}
602				break;
603			}
604		}
605	}
606}
607var ytFirstStart = false;
608function onYTPlayerStateChange(event) {
609	var tmp_id = "";
610	var tmp_title = "";
611	var obj = event.target;
612	for (var key in obj) {
613		if (Object.prototype.hasOwnProperty.call(obj, key)) {
614			var val = obj[key];
615			if (val.nodeName === "IFRAME") {
616				tmp_id = urldecode(val.id);
617				var tmp_obj = YT.get(tmp_id);
618				if (typeof tmp_obj.getVideoData === "function") {
619					tmp_title = tmp_obj.getVideoData().title;
620				} else {
621					var tmp_url = tmp_obj.getVideoUrl();
622					var tmp_match = tmp_url.match(/[?&]v=([^&]+)/);
623					tmp_title = tmp_match[1]; // videoID
624				}
625				// doLog("onYTPlayerStateChange, " + tmp_id + ", " + tmp_title);
626				switch (event.data) {
627					case -1:
628						doLog("video: unstarted (" + tmp_title + ")");
629						if (tmp_id.indexOf("playlist") !== -1) {
630							updateYTVideoNav(tmp_id);
631						}
632						break;
633					case 0:
634						doTrack('Video','VideoFinish',tmp_title);
635						break;
636					case 1:
637						if (ytFirstStart == false) {
638							ytFirstStart = true;
639							doTrack('Video','VideoStart',tmp_title);
640						} else {
641							doTrack('Video','VideoResume',tmp_title);
642						}
643						break;
644					case 2:
645						doTrack('Video','VideoPause',tmp_title);
646						break;
647					case 3:
648						doLog("video: buffering (" + tmp_title + ")");
649						break;			
650					case 5:
651						doLog("video: cued (" + tmp_title + ")");
652						break;
653					default:
654						break;
655				}
656				break;
657			}
658		}
659	}
660}
661var ytPlaylistIDs, ytPlaylistTitles, ytPlaylistPos, ytPlaylistSize;
662function getYTPlaylist(list,iframe_id) {
663	var playListURL = "https://www.googleapis.com/youtube/v3/playlistItems?maxResults=30&part=snippet&playlistId=" + list 
663+ "&key=" + ytApiKey;
664	ytPlaylistIDs = new Array();	
665	ytPlaylistTitles = new Array();	
666	ytPlaylistPos = 0;
667	ytPlaylistSize = 0;	
668	$.get(playListURL,function(data) {
669		ytPlaylistSize = data.items.length;
670		$.each(data.items, function(i, item) {
671			ytPlaylistIDs.push(item.snippet.resourceId.videoId);
672			ytPlaylistTitles.push(item.snippet.title);
673		});
674		// doLog(ytPlaylistIDs); // doLog(ytPlaylistTitles);
675		updateYTVideoNav(iframe_id);
676		if (ytPlaylistIDs.length > 1) {
677			$("#video .video_nav_holder").slideDown("slow",function() { sRefresh(); });
678		}
679	});
680}
681function updateYTVideoNav(iframe_id) {
682	ytPlaylistPos = YT.get(iframe_id).getPlaylistIndex();
683	// doLog("updateYTVideoNav(" + iframe_id + ") -> ytPlaylistPos: " + ytPlaylistPos);
684	$("#video .video_nav_prev a").attr("onClick","previousYTVideo('" + iframe_id + "')");
685	$("#video .video_nav_next a").attr("onClick","nextYTVideo('" + iframe_id + "')");
686	$("#video .video_title").html(ytPlaylistTitles[ytPlaylistPos]);
687	var ytPlaylistPosDisplay = ytPlaylistPos + 1;
688	if (ytPlaylistPosDisplay < 10) { ytPlaylistPosDisplay = "0" + ytPlaylistPosDisplay; }
689	var ytPlaylistSizeDisplay = ytPlaylistSize;
690	if (ytPlaylistSizeDisplay < 10) { ytPlaylistSizeDisplay = "0" + ytPlaylistSizeDisplay; }
691	$("#video .video_nav .video_nav_counter").html(ytPlaylistPosDisplay + " / " + ytPlaylistSizeDisplay);
692}
693function playYTVideo(iframe_id) {
694	YT.get(iframe_id).playVideo();
695}	
696function pauseYTVideo(iframe_id) {
697	YT.get(iframe_id).pauseVideo();
698}	
699function stopYTVideo(iframe_id) {
700	YT.get(iframe_id).stopVideo();
701}
702function previousYTVideo(iframe_id) {
703	YT.get(iframe_id).previousVideo();	
704}
705function nextYTVideo(iframe_id) {
706	YT.get(iframe_id).nextVideo();	
707}
708
709// ------------------------ products ------------------------ //
710
711function toggleAlbumplayer(section, id) {
712    doLog("toggleAlbumplayer(" + section + ", " + id + ")");
713	if ($("." + section + " #albumplayer" + id).css("display") === "none") {
714		// close other players
715		$("." + section + " .albumplayer").empty();
716		$("." + section + " .albumplayer").css("display","none");
717		$("." + section + " .item li.albumplayer_trigger .title_off").css("display","block");
718		$("." + section + " .item li.albumplayer_trigger .title_on").css("display","none");
719		$("." + section + " .item .imageborder_holder").css("opacity", 1);
720		// load specific player
721		var txt = $("#" + section + " #albumplayer" + id).data("embedcode");
722		$("." + section + " #albumplayer" + id).html(urldecode(txt));
723		$("." + section + " #albumplayer" + id).css("display","block");
724		$("#" + section + id + " li.albumplayer_trigger .title_off").css("display","none");
725		$("#" + section + id + " li.albumplayer_trigger .title_on").css("display","block");
726		$("#" + section + id + " .imageborder_holder").css("opacity", 0);
727		doLog("hide: " + "#" + section + id + " .imageborder_holder");
728		doScroll("#" + section + " #albumplayer" + id);
729	} else {
730		$("." + section + " #albumplayer" + id).empty();
731		$("." + section + " #albumplayer" + id).css("display","none");
732		$("#" + section + id + " li.albumplayer_trigger .title_off").css("display","block");
733		$("#" + section + id + " li.albumplayer_trigger .title_on").css("display","none");
734		$("#" + section + id + " .imageborder_holder").css("opacity", 1);
735	}
736}
737
738// ------------------------ news ------------------------ //
739function toggleNews(id) {
740	if (id) {
741		var el = $("#news_items .item" + id);
742		if (el.hasClass("on")) {
743			el.removeClass("on");
744		} else {
745			el.addClass("on");
746		}
747	}
748}
749
750// ------------------------ dates ------------------------ //
751function toggleDates(id) {
752	var new_h, row_display;
753	// get modus (compact, large) usually triggered via @media screen and (max-width:640px) { }
754	if ($("#dates_block" + id + " .dateslist li").first().css("display") === "table") {
755		row_display = "table";
756	} else {
757		row_display = "block";
758	}
759	if ($("#dates_block" + id + " .dateslist li.row-more").css("display") === "none") {
760		// show more rows
761		new_h = $("#dates_block" + id + " .dateslist").innerHeight();
762		$("#dates_block" + id + " .dateslist_holder").css("height", new_h + "px");
763		$("#dates_block" + id + " .dateslist li.row-more").css("display",row_display);
764		new_h = $("#dates_block" + id + " .dateslist").innerHeight();
765		$("#dates_block" + id + " .dateslist_holder").animate({ height: new_h }, "slow", function() {
766			$("#dates_block" + id + " .dateslist_holder").css("height", "auto");
767			$("#dates_block" + id + " .more_dates a.icon-down-open").css("display","none");
768			$("#dates_block" + id + " .more_dates a.icon-up-open").css("display","inline-block");
769			sRefresh();
770  		});	
771	} else {
772		// show less rows
773		$("#dates_block" + id + " .dateslist li.row-more").css("display","none");
774		new_h = $("#dates_block" + id + " .dateslist").innerHeight();
775		$("#dates_block" + id + " .dateslist li.row-more").css("display",row_display);
776		$("#dates_block" + id + " .dateslist_holder").animate({ height: new_h }, "slow", function() {
777			$("#dates_block" + id + " .dateslist li.row-more").css("display","none");
778			$("#dates_block" + id + " .dateslist_holder").css("height", "auto");
779			$("#dates_block" + id + " .more_dates a.icon-down-open").css("display","inline-block");
780			$("#dates_block" + id + " .more_dates a.icon-up-open").css("display","none");
781			$.scrollTo("#dates_block" + id + " .more_dates", 1000, {
782				axis: "y",
783				offset: -220,
784				onAfter: function () {
785				}
786			});
787			sRefresh();
788  		});
789	}
790}
791
792function toggleCalendar(id) {
793	if ($(".calendar_links" + id).css("display") === "none") {
794		$(".calendar_toggle" + id).text("-");
795		$(".calendar_links" + id).fadeIn("fast", function() { });
796        setTimeout(function(){
797            $(document).click(function(e) {
798                if (!$(e.target).closest(".calendar_links" + id).length) {
799                    // alert('click outside!');
800                    $(".calendar_toggle" + id).text("+");	
801                    $(".calendar_links" + id).fadeOut("fast", function() { });
802                    $(document).unbind("click");
803                }
804            });
805        }, 200);
806	} else {
807		$(".calendar_toggle" + id).text("+");	
808		$(".calendar_links" + id).fadeOut("fast", function() { });
809        $(document).unbind("click");
810	}
811}
812
813function getBio(nr,bg) {
814	$("#bio ul.sub_nav li").removeClass("on");
815	$("#bio ul.sub_nav li").addClass("off");
816	// var bg_empty = "url(/" + base + "/images/layout/pix.gif)";
817	// if (bg == "") { bg = bg_empty; }
818	$("#bio .bio_container").slideUp("slow", function() {
819		// $("#bio").css("background-image",bg_empty);
820		$("#bio ul.sub_nav li.type" + nr).addClass("on");
821		$("#bio .bio_container .item").css("display","none");
822		$("#bio .bio_container .item" + nr).css("display","block");
823		setTimeout(function(){
824			$("#bio .bio_container").slideDown("slow", function() {
825				// $("#bio").css("background-image",bg);
826				sRefresh();
827			});
828		}, 500);
829	});
830}
831
832// ------------------------ audio ------------------------ //
833
834var playlist;
835var playlist_pos = -1;
836var play_modus = "manual";
837var oldTrack = null;
838var audioFirstStart = false;
839
840function initMusicplayer() {
841	$("#musicplayer").attr("oncanplay", "canPlay();");
842	$("#musicplayer").attr("onended", "playNext();");
843}
844
845function playTrack(id) {
846	// alert("playTrack(" + id + "), oldTrack: " + oldTrack);
847	var audio = document.getElementById("musicplayer");
848	id = parseInt(id);
849	playlist_pos = $.inArray(id, playlist);
850	doLog("playTrack(" + id + "), my playlist_pos:" + playlist_pos);
851	if (oldTrack == id) {
852		if (audio.paused) {
853			doPlay();
854		} else {
855			doPause();
856		}	
857	} else {
858		audio.addEventListener("timeupdate", progressBar, true);
859		var trackname = $("#track"+ id).data("trackname");
860		$(".track").removeClass("track_on");
861		$(".track .playback_icon").html("<div class='icon icon-play'></div>");
862		$(".track .track_progress").css("width","0%");
863		$("#track"+ id).addClass("track_on");
864		$("#track"+ id + " .playback_icon").html("<div class='icon icon-spin5 animate-spin'></div>");
865		oldTrack = id;
866		audioFirstStart = false;
867		audio.src = $("#track"+ id).data("src");
868		audio.load();
869	}	
870}
871
872function canPlay() {
873    if (play_modus == "auto" || play_modus == "manual") {
874        doPlay();
875    } else {
876		doPause();
877	}
878}
879
880function doPlay() {
881	var audio = document.getElementById("musicplayer");
882    audio.play();
883	$("#track"+ oldTrack + " .playback_icon").html("<div class='icon icon-pause'></div>");
884	if (audioFirstStart == false) {
885		audioFirstStart = true;
886		doTrack('Audio','AudioStart',$("#track"+ oldTrack).data("trackname"));
887	} else {
888		doTrack('Audio','AudioResume',$("#track"+ oldTrack).data("trackname"));
889	}
890}
891
892function doPause() {
893	var audio = document.getElementById("musicplayer");
894	if (!audio.ended) {
895		doTrack('Audio','AudioPause',$("#track"+ oldTrack).data("trackname"));
896	}
897	if (audio.ended) {
898		$("#track"+ oldTrack + " .track_progress").css("width", "0%");
899		doTrack('Audio','AudioFinish',$("#track"+ oldTrack).data("trackname"));
900	}
901    audio.pause();
902	$("#track"+ oldTrack + " .playback_icon").html("<div class='icon icon-play'></div>");
903}
904
905function doStop() {
906	doLog("doStop()");
907	var audio = document.getElementById("musicplayer");
908 	if (audio) {
909		audio.pause();
910		if (oldTrack) {
911			doTrack('Audio','AudioStop',$("#track"+ oldTrack).data("trackname"));
912		}
913		$("#track"+ oldTrack + " .track_progress").css("width", "0%");
914		$("#track"+ oldTrack + " .playback_icon").html("<div class='icon icon-play'></div>");
915		oldTrack = null;
916		playlist_pos = -1;
917 	}
918}
919
920function playPause() {
921	var audio = document.getElementById("musicplayer");
922    if (audio.paused) {
923        doPlay();
924    } else {
925        doPause();
926    }
927}
928
929function playNext() {
930	if (typeof(playlist) != "undefined") {
931		doLog("playNext(), playlist.length:" + playlist.length + ", playlist_pos:" + playlist_pos)
932		if (play_modus == "auto") {
933			playlist_pos++;
934			if (playlist_pos < playlist.length) {
935				var next_id = playlist[playlist_pos];
936				doLog("next_id: " + next_id + ", playlist_pos:" + playlist_pos);
937				doTrack('Audio','AudioGotoNextTrack',$("#track"+ next_id).data("trackname"));
938				playTrack(next_id);
939			} else {
940				playlist_pos = -1;
941				doLog("playlist end");
942				doPause();	
943			}
944		} else {
945			doPause();	
946		}
947	}
948}
949
950function progressBar() { 
951	var oAudio = document.getElementById("musicplayer");	
952	var elapsedTime = Math.round(oAudio.currentTime); // get current time in seconds
953	var w = (elapsedTime / oAudio.duration) * 100; // update the progress bar
954	if (w >= 0 && w <= 100) {
955		// doLog("audio-progress: " + w);
956		$("#track"+ oldTrack + " .track_progress").css("width", w + "%");
957	}
958}
959
960
961// ------------ bg-video ------------ //
962
963function load_bg_video(src,id,loop) {
964	// doLog("load_bg_video(" + src + "," + id + "," + loop + ")");
965	var loop_str = "";
966	var onended_str = "";
967	if (loop == "Y") {
968		loop_str = "loop";
969	} else {
970		onended_str = "hide_bg_video('bg_video" + id + "');";	
971	}
972	var txt = "";
973	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 + "\">";
974	txt += "<source src=\"" + src + "\" type=\"video/mp4\">";
975	txt += "</video>";
976	txt += "<div class=\"fg_video fg_video_on\"></div>";
977	$("#bg_video_holder" + id).html(txt);
978}
979
980function show_bg_video(id) {
981	if ($("#" + id).hasClass("bg_video_off")) {
982		if (id == "bg_video-bg-0") {
983			var vid = document.getElementById(id);
984			vid.playbackRate = 1;
985		}
986		// doLog("show_bg_video(" + id + ")");
987		$("#" + id).removeClass("bg_video_off");
988		$("#" + id).addClass("bg_video_on");
989		$("#" + id).attr("onCanPlay","");
990	}
991}
992
993function hide_bg_video(id) {
994	$("#" + id).removeClass("bg_video_on");
995	$("#" + id).addClass("bg_video_off");
996}
997
998
999function volume_bg_video(vol) {
1000	var vid = $(".slides .bg_video");
1001	vid.animate({volume: vol}, 1000, 'swing', function() {
1002    	// $(".slides .bg_video").each(this.pause()); // pause video
1003    });
1004}
1005
1006function toggle_bg_video() {
1007	/*
1008	var video = document.getElementById('bg_video_main');
1009	if (bgVideo) {
1010		$(".bg_video_ctrl").removeClass("bg_video_ctrl_on");
1011		if (video) { video.pause(); }
1012		$(".bg_video_holder").hide();
1013		bgVideo = false;
1014	} else {
1015		$(".bg_video_ctrl").addClass("bg_video_ctrl_on");
1016		if (video) { video.play(); }
1017		$(".bg_video_holder").show();
1018		bgVideo = true;
1019	}
1020	*/
1021}
1022
1023
1024// ------------ forms + newsletter ------------ //
1025
1026function validateEmail(email) { 
1027	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,}))$/;
1028	return exp.test(email);
1029}
1030
1031var warnTimeout;
1032
1033function doWarn(id,txt) {
1034	// alert("doWarn(" + id + "," + txt + ")");
1035	$("#"+id).addClass("warning");
1036	$("label[for='"+ id +"']").html("<span class='icon icon-attention'></span> " + txt);
1037	$("label[for='"+ id +"']").addClass("warning");
1038	/*
1039	// make it shake!
1040	$(elem).addClass("animated_manual_animation shake").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function(){
1041    	$(elem).removeClass("animated_manual_animation");
1042		$(elem).removeClass("shake");
1043    });
1044	*/
1045	$("#"+id).disabled = false;
1046	$("#"+id).trigger("focus");
1047	
1048	clearTimeout(warnTimeout);
1049	warnTimeout = setTimeout(function(){ 
1050		resetFormWarnings();
1051	}, 5000);
1052}
1053
1054function resetFormWarnings() {
1055	$("form .text").removeClass("warning");
1056	$("form label").removeClass("warning");
1057	$("form label").each(function(index) {
1058		var myText = $(this).attr('data-text');
1059		if (myText !== undefined) {
1060			$(this).html(urldecode(myText));
1061		}
1062	});
1063}
1064
1065function checkInput(id, title, allow_empty) {
1066	title = urldecode(title);
1067	input = $("#" + id);
1068	if (allow_empty === undefined) { allow_empty = false; }
1069	if (allow_empty == false) {
1070		if (input.val() === "" || input.val().length < 2) {
1071			doWarn(id, title + " is missing.");
1072			return false;
1073		}
1074	}
1075	var zeichen ="<>";
1076	var eingabe = input.val();
1077	var laenge = eingabe.length;
1078	for(i=0; i<laenge;  i++) {
1079	  	badchar = eingabe.charAt(i);
1080	  	if (zeichen.indexOf(badchar)>-1) {
1081			doWarn(id, title + " contains invalid letters.");
1082			return false;
1083		}
1084	}
1085	return true;
1086}
1087
1088function checkText(id, title, allow_empty) {
1089	input = $("#" + id);
1090	if (allow_empty === undefined) { allow_empty = false; }
1091	if (allow_empty == false) {
1092		if (input.val() === "" || input.val().length < 24) {
1093			doWarn(id, title + " fehlt.");
1094			return false;
1095		}
1096	}
1097	return true;
1098}
1099
1100function checkCharCount(el) {
1101	var str = $("#" + el).val();	
1102	if ($("#" + el).val().length >= maxChars) {
1103		doWarn(el, "This field contains too much letters.");
1104	}
1105}
1106
1107function checkUrl(id, title, allow_empty) {
1108	input = $("#" + id);
1109	if (allow_empty === undefined) { allow_empty = false; }
1110	if (allow_empty == false) {
1111		if (input.val() === "" || input.val().length < 2) {
1112			doWarn(id, title + " is missing.");
1113			return false;
1114		}
1115	}
1116	var zeichen =";<>";
1117	var eingabe = input.val();
1118	var laenge = eingabe.length;
1119	for(i=0; i<laenge;  i++) {
1120	  	badchar = eingabe.charAt(i);
1121	  	if (zeichen.indexOf(badchar)>-1) {
1122			doWarn(id, title + " contains invalid letters.");
1123			return false;
1124		}
1125	}
1126	if (eingabe.indexOf("http") !== 0) {
1127		doWarn(id, title + " must start with http or https.");
1128		return false;
1129	}
1130	return true;
1131}
1132
1133function doFeedback(id,txt) {
1134	$("#"+ id + " .content").html(txt);
1135	$("#" + id).slideDown("slow");
1136	setTimeout(function() { $("#" + id + " a.close").fadeIn("slow"); }, 3000);
1137}
1138
1139function closeFeedback(id) {
1140	$("#" + id + " a.close").fadeOut("fast");
1141	$("#" + id).fadeOut("slow");
1142}
1143
1144function sendnewsletter() {
1145	doLog("sendnewsletter()");	
1146
1147	// check email
1148	if (document.getElementById("nl_email_id")) {
1149		if (!checkInput("nl_email_id", "E-mail")) { return false; }
1150		if (!validateEmail($("#nl_email_id").val())) {
1151			doWarn("nl_email_id", "The E-mail is invalid.");
1152			return false; 
1153		}
1154	}
1155
1156	// check firstname
1157	if (document.getElementById("nl_firstname_id")) {
1158		if (!checkInput("nl_firstname_id", "Firstname", true)) { return false; }
1159	}
1160    
1161	// check city
1162	if (document.getElementById("nl_city_id")) {
1163		if (!checkInput("nl_city_id", "City", true)) { return false; }
1164	}
1165	
1166	// check country
1167	if (document.getElementById("nl_country_id")) {
1168		if (!checkInput("nl_country_id", "Country")) { return false; }
1169	}
1170
1171	// check question
1172	if (document.getElementById("nl_question_id")) {
1173		if (!checkInput("nl_question_id", "Anti-Spam answer")) { return false; }
1174	}
1175    
1176	// send data
1177	var post_data = $("#nl_sender_form").serialize();
1178	
1179	// add pers_lytics_uid
1180    /*
1181	if (window.hasOwnProperty('lio')) {
1182		post_data += "&pers_lytics_uid=" + window.lio._uid;
1183	} else {
1184		post_data += "&pers_lytics_uid=";
1185	}
1186    */
1187	// doLog("post_data:"); doLog(post_data);
1188	
1189	$.ajax({
1190		url: "/" + base + "/section_newsletter_sender.php",
1191		data: post_data,
1192		method: "POST",
1193		dataType: "html",
1194		cache: false,
1195		beforeSend: function() {
1196			$("#nl_btn_send_holder").slideUp("fast");
1197			doFeedback("nl_feedback_id","<span class='icon icon-spin5 animate-spin'></span> One moment please...");
1198		},
1199		success: function(data) {
1200			doFeedback("nl_feedback_id",data);
1201			if (data.search(/error/i) == -1 && data.search(/fehler/i) == -1 && data.search(/erreur/i) == -1) {
1202				// feedback contains no errors:
1203				$("#nl_feedback_id a.close").remove();
1204			} else {
1205				$("#nl_btn_send_holder").slideDown("fast");
1206			}
1207		},
1208		error: function(XMLHttpRequest, textStatus, errorThrown) {
1209			alert("Error: " + errorThrown + "(" + XMLHttpRequest.status + ")");
1210			$("#nl_btn_send_holder").slideDown("fast");
1211		},
1212		complete: function() {
1213			//
1214		}
1215	});
1216	
1217	return false;
1218}
1219
1220
1221
1222// ------------ standard functions ------------ //
1223
1224var resized;
1225
1226function initResize() {
1227	doLog("initResize");
1228	$(window).on('resize orientationChanged', function() {
1229		$("#body_id").addClass("resize");
1230		clearTimeout(resized);
1231		resized = setTimeout(onResize, 150);
1232	});
1233}
1234
1235function initCookieConsent() {
1236    window.cookieconsent.initialise({
1237        "palette":{
1238            "popup":{
1239                "background":"rgba(0,0,0,0.6)"
1240            },
1241            "button":{
1242                "color":"#e1bf66",
1243                "background":"#000",
1244                "border":"1px solid #e1bf66",
1245           },
1246        },
1247        content:{
1248            message:'This website uses',
1249            dismiss:'OK',
1250            link:'Cookies',
1251            href:'/privacy/'
1252        }
1253    });
1254}
1255
1256function disableRightClick() {
1257	$('img').on('dragstart', function(event) { event.preventDefault(); });
1258	$("body").on("contextmenu", "img", function(e) {
1259	  return false;
1260	});
1261}
1262
1263function initCopyButtons() {
1264	// doLog("initCopyButtons()");
1265	var clipboard = new ClipboardJS(".copy-button");
1266	clipboard.on('success', function(e) {
1267		// console.info('Action:', e.action); console.info('Text:', e.text); console.info('Trigger:', e.trigger);
1268		e.clearSelection();
1269		if (lang == "de") {
1270			doMsg("<span class='icon icon-ok'></span> Link kopiert");
1271		} else {
1272			doMsg("<span class='icon icon-ok'></span> Link copied");	
1273		}
1274		setTimeout(function() { closeMsg(); }, 3000);
1275	});
1276	var emailclipboard = new ClipboardJS('a.copy-email', {
1277        text: function(trigger) {
1278            return trigger.getAttribute('data-usr') + "@" + trigger.getAttribute('data-dom') + "." + trigger.getAttribute('data-tld');
1279        }
1280    });
1281	emailclipboard.on('success', function(e) {
1282		// console.info('emailclipboard Action:', e.action); console.info('emailclipboard Text:', e.text); console.info('Trigger:', e.trigger);
1283		e.clearSelection();
1284		doMsg("<span class='icon icon-ok'></span> E-Mail kopiert");
1285		if (lang == "de") {
1286			doMsg("<span class='icon icon-ok'></span> E-Mail kopiert");
1287		} else {
1288			doMsg("<span class='icon icon-ok'></span> E-Mail copied");	
1289		}
1290		setTimeout(function() { closeMsg(); }, 3000);
1291	});
1292}
1293
1294function doMsg(txt) {
1295	// if ($("#msg .content").html() != "") { doAnim("#msg", "flash"); }
1296	$("#msg .content").html(urldecode(txt));
1297	$("#msg").slideDown('fast', function() {});
1298}
1299
1300function closeMsg() {
1301	if (window.jQuery) {
1302		$("#msg").slideUp("fast", function() { $("#msg .content").empty(); });
1303	} else {
1304		document.getElementById('msg').children[0].innerHTML='';document.getElementById('msg').style.display='none';
1305	}
1306}
1307
1308function setShare(id, url, title) {
1309	var txt = '';
1310	txt += '<div class="share_tools" data-url="' + url + '" data-title="' + title + '">';
1311	txt += '<a class="button share_facebook" href="#" onclick="doShare(event,\'facebook\');return false;" title="Share on facebook"><span class="icon icon-facebook"></span></a>';
1312	// 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>';
1313	txt += '<a class="button share_whatsapp" href="#" onclick="doShare(event,\'whatsapp\');" title="Share with whatsapp"><span class="icon icon-whatsapp"></span></a>';
1314	txt += '<a class="button share_twitter" href="#" onclick="doShare(event,\'twitter\');return false;" title="Tweet"><span class="icon icon-twitter"></span></a>';
1315	// txt += '<a class="button share_email" href="#" onclick="doShare(event,\'email\');" title="Share via email"><span class="icon icon icon-mail"></span></a>';
1316	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>'; 
1317	txt += '</div>';
1318	$('#' + id).empty().append(txt);
1319	initCopyButtons();
1320}
1321
1322function toggleShare(event) {
1323	$(event.target).closest(".share_tools").toggleClass("on");
1324}
1325
1326function doShare(event, network) {
1327	// doMsg("doShare(" + network + ")");doLog("event:");doLog(event);
1328	var share_el,share_container,url,title,share_window;
1329	// get data-url & data-title from parent div.share_tools
1330	if (event.target.parentNode.className == "share_tools") {
1331		// old safari
1332		share_el = event.target;
1333		share_container = event.target.parentNode;
1334	} else {
1335		share_el = event.target.parentNode;
1336		share_container = event.target.parentNode.parentNode;
1337	}
1338	// doLog("share_container:");doLog(share_container);
1339	url = share_container.dataset.url;
1340	title = share_container.dataset.title;
1341	// doLog("data:");doLog(url);doLog(urldecode(title));doMsg("url: " + urldecode(url) + "<br>title: " + urldecode(title));
1342	switch(network) {
1343		case "facebook":
1344			doTrack('Social', "FacebookShare", urldecode(url));
1345			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");
1346			share_window.focus();
1347			break;
1348		case "twitter":
1349			doTrack('Social', "TwitterShare", urldecode(url));
1350			title = urldecode(title);
1351			title = encodeURIComponent(title);
1352			$(window).bind("message", function(event) { event = event.originalEvent; if (event.source == share_window && event.data != "__ready__") { doLog("tweet successful"); } });
1353			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");
1354			share_window.focus();
1355			break;
1356		case "email":
1357			doTrack('Social', "EmailShare", urldecode(url));
1358			title = urldecode(title);
1359			title = encodeURIComponent(title);
1360			share_el.href = "mailto:?subject=" + title + "&body=" + url;
1361			break;	
1362		case "whatsapp":
1363			doTrack('Social', "WhatsappShare", urldecode(url));
1364			share_el.href = "whatsapp://send?text=" + title + encodeURIComponent(": ") + url;
1365			break;
1366		case "facebook_messenger":
1367			doTrack('Social', "FacebookMessengerShare", urldecode(url));
1368			share_el.href = "fb-messenger://share?link=" + url;
1369		default:
1370			break;
1371	}
1372}
1373
1374function toggleTab(nr) {
1375	$(".tabs .tabheader li").removeClass("on");
1376	$(".tabs .tab").slideUp("fast");
1377	setTimeout(function() {
1378		$(".tabs .tabheader li.tab" + nr + "toggle").addClass("on");
1379		$(".tabs .tab" + nr).slideDown("slow", function() {});
1380	}, 400);
1381}
1382
1383function toggleMenu() {
1384	if ($("#body_id").hasClass("menu_on")) {
1385		$("#body_id").removeClass("menu_on");
1386	} else {
1387		$("#body_id").addClass("menu_on");
1388	}
1389}
1390
1391function doScroll(el) {
1392	doLog("doScroll(" + el + ")");
1393	yOffset = -1 * $(".header_norm").outerHeight();
1394	yOffset -= 0;
1395	$.scrollTo(el, 800, {
1396		axis: "y",
1397		offset: yOffset,
1398		onAfter: function () {
1399		}
1400	});
1401}
1402
1403function initNav() {
1404	$('.header_norm .nav_list a.page_link').on("click", function(){
1405		doShow($(this).data('href'),"",0);
1406		return false;
1407	});
1408	$('.nav_overlay .nav_list a.page_link').on("click", function(){
1409		doShow($(this).data('href'),"",0);
1410		toggleMenu();
1411		return false;
1412	});
1413	var sections = $('section');
1414	var waypoints = sections.waypoint({
1415		handler: function(direction) {
1416			var active_id = this.element.id;
1417			// doLog(active_id + ' hit 40% from top of window');
1418			if (direction === 'up'){ active_id = $("#" + active_id).prev().attr('id'); }
1419			// if (direction === 'down'){ active_id = $("#" + active_id).next().attr('id'); }
1420			$('.nav_list ul li.nav_page').removeClass('on');
1421			$('.nav_list ul li.nav_' + active_id).addClass('on');
1422			// setHash(sectionId); // 2do: if not scrolling because of doShow(), leads to blinks while auto-scrolling (ie, ff)
1423		},
1424		offset: '35%'
1425	});
1426	var waypoint = new Waypoint({
1427		element: $('#header_bottom'),
1428		handler: function(direction) {
1429			// doLog('Scrolled to #header_bottom, Direction: ' + direction);
1430			if (direction === 'up'){
1431				$("#body_id").removeClass("compact");
1432			}
1433			if (direction === 'down'){
1434				$("#body_id").addClass("compact");
1435			}
1436		},
1437		offset: -350
1438	});
1439}
1440
1441function initFancybox() {
1442	$.fancybox.defaults.buttons = ['close']; // 'fullScreen','slideShow',
1443	$.fancybox.defaults.hash = false;
1444	$.fancybox.defaults.loop = true;
1445	$.fancybox.defaults.backFocus = false;
1446	// $.fancybox.defaults.hideScrollbar = true;
1447	// $.fancybox.defaults.margin = [0,0];
1448}
1449
1450function doTruncate(identifier, limit) {
1451    switch (lang) {
1452        case "de":
1453            var showText = "Mehr anzeigen";
1454            var hideText = "Weniger anzeigen";
1455            break;
1456        case "fr":
1457            var showText = "Voir Plus";
1458            var hideText = "Voir Moins";
1459            break;
1460        default:
1461            var showText = "Show more";
1462            var hideText = "Show less";
1463            break;
1464    }
1465	if (isNaN(limit)) { limit = 7; }
1466	$(identifier).truncate({
1467		"maxLines": limit,
1468		"truncateString": "&nbsp;&#8230;",
1469		"showText": "<div class='more clearfix'><span class='border title'>" + showText + "</span>&nbsp;<span class='icon icon-down-open'></span></div>",
1470		"hideText": "<div class='more clearfix'><span class='border title'>" + hideText + "</span>&nbsp;<span class='icon icon-up-open'></span></div>",
1471		"animate": true,
1472		"animateOptions": { 'complete': function() {
1473			$(identifier).css("height","auto");
1474			sRefresh();
1475			if ($(this).data("status") === "open") {
1476				$(this).data("status","closed");
1477				var yOffset = -1 * $(".header_compact").height();
1478				yOffset -= 10;
1479				var myId = $(this).attr("id");
1480				if (!myId) {
1481					myId = "trunc_" + myRandom(100000, 999999);
1482					$(this).attr("id",myId);
1483				}
1484				var target = $("#" + myId);
1485				$.scrollTo(target, 1000, {
1486					axis: "y",
1487					offset: yOffset,
1488					duration: 3000,
1489					onAfter: function () {
1490                        try { $(".carousel-products").flickity('resize'); } catch (e) { }
1491                    }
1492				});
1493			} else {
1494				$(this).data("status","open");
1495                try { $(".carousel-products").flickity('resize'); } catch (e) { }
1496			}
1497		} }
1498	});
1499}
1500
1501function urldecode(str) {
1502	return decodeURIComponent((str+'').replace(/\+/g, ' '));
1503}
1504
1505function doLog(txt) {
1506	node = document.getElementById("log");
1507	if (node) { node.innerHTML = txt + "<br>" + node.innerHTML; }
1508    if (page_mode == "dev") { if (console) { console.log(txt); } } // if (window.location.hostname.indexOf(".local") != -1) { if (console) { console.log(txt); } }
1509}
1510
1511function doTrack(category, action, label) {
1512	if (category != "" && action != "") {
1513		// umg-tracking
1514		// if (category == "CRM" || category == "Video" || category == "Audio" || category == "Social") { dataLayer.push({'event':'GAEvent', 'attributes': {'eventCategory': '' + category + '', 'eventAction': '' + action +'', 'eventLabel': '' + label + '' }}); }
1515		// analytics.js
1516		// ga('send', 'event', category, action, label);
1517		// ga.js:
1518		// _gaq.push(['_trackEvent', category, action, label]);	
1519	}
1520	doLog("doTrack(" + category + " | " + action + " | " + label + ")");
1521}
1522
1523function initSvg(el) {
1524    var element = "";
1525    if (el) { element = el + " "; }
1526    $(element + 'img.svg').each(function(){
1527        var $img = $(this); var imgID = $img.attr('id'); var imgClass = $img.attr('class'); var imgURL = $img.attr('src');
1528        $.get(imgURL, function(data) {
1529            var $svg = $(data).find('svg');
1530            if (typeof imgID !== 'undefined') { $svg = $svg.attr('id', imgID); }
1531            if (typeof imgClass !== 'undefined') { $svg = $svg.attr('class', imgClass+' replaced-svg'); }
1532            $svg = $svg.removeAttr('xmlns:a'); $img.replaceWith($svg);
1533        }, 'xml');
1534    });
1535}
1536
1537function getCacheControl() {
1538	var date = new Date();
1539	var year = date.getUTCFullYear();
1540	var month = date.getUTCMonth(); 
1541	month++; // (from 0-11)
1542	if (month < 10) { month = "0" + month; }
1543	var day = date.getUTCDate();
1544	if (day < 10) { day = "0" + day; }
1545	var hour = date.getUTCHours();
1546	if (hour < 10) { hour = "0" + hour; }
1547	var minutes = date.getUTCMinutes();
1548	switch(true) { case minutes>45:minutes="45";break; case minutes>30:minutes="30";break; case minutes>15:minutes="15";break; default:minutes="00";break; }
1549	var c = year + month + day + "-" + hour + minutes;
1550	return c;
1551}
1552
1553function inIframe() {
1554    try {
1555        return window.self !== window.top;
1556    } catch (e) {
1557        return true;
1558    }
1559}
1560
1561function checkLinks() {
1562    $('a[href^="http"]').not('a[href*="' + location.hostname + '"]').attr({target: "_blank", rel: "noopener"});
1563}
1564
1565function winopen(url,name,w,h) {
1566	var w_shift = Number((screen.width/2)-(w/2));
1567	var h_shift = Number((screen.height/2)-(h/2));
1568	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);
1569	newWin.focus();
1570}
1571
1572function capitalizeFirstLetter(string) {
1573    return string.charAt(0).toUpperCase() + string.slice(1);
1574}
1575
1576function getCookieValue(a) { // thx 2 mac: http://stackoverflow.com/questions/5639346/#answer-25490531
1577    var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)');
1578    return b ? b.pop() : '';
1579}
1580
1581function getRequestVar(name){
1582	if (name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)) { return decodeURIComponent(name[1]); }
1583}
1584
1585function kill(id) {
1586	element = document.getElementById(id);
1587 	if (element) {
1588  		var parent = element.parentNode;
1589  		if (parent) {
1590			parent.removeChild(element);
1591		}
1592 	}
1593 	return false;
1594}
1595
1596// 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));
1597function shuffle(v) {
1598    for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);
1599    return v;
1600};
1601
1602function myRandom(a, b) {
1603	if (a > b) { return(-1); }
1604	if (a === b) { return(a); }
1605	return a + parseInt(Math.random() * ( b - a+1 ));
1606}
1607
1608// 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.