PageSourceSearch

https://schilthorn.ch/scripts/common.v4.js?v=1

js schilthorn.ch collected 2026-09-24 18:55:19 UTC 18,812 bytes, 732 lines download raw bytes

1/*
2 * JavaScript Library.
3 *
4 * @name $Id: common.v4.js
5
6 * This is a commercial software product, please visit http://artasio.com for more information.
7 */
8var $currentScrollPos = 0;
9
10function openInfoWindow (url) {
11	var screen_width, screen_height;
12	var win_top, win_left;
13	var InfoWindow;
14
15	screen_height        = 0;     screen_width      = 0;
16	win_top              = 0;     win_left          = 0;
17
18	var help_win_width   = 650;
19	var help_win_height  = 650;
20
21	if (window.innerWidth) screen_width = window.innerWidth;
22	if (window.innerHeight) screen_height = window.innerHeight;
23
24	win_top  = screen_height - help_win_height - 20;
25	win_left = screen_width  - help_win_width  - 20;
26	InfoWindow  = window.open(
27		url,
28		'Drucken',
29		'width='+help_win_width+',height='+help_win_height+',top='+win_top+',left='+win_left+',scrollbars=yes,menubar=no'
30	);
31	InfoWindow.focus();
32}
33
34/*
35 * Image gallery click event. Add a trigger event to the actual click event in browsers that don't let you
36 * click() directly.
37 */
38if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.click) {
39	HTMLElement.prototype.click=function() {
40		var evt = this.ownerDocument.createEvent('MouseEvents');
41		evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
42		this.dispatchEvent(evt);
43	}
44}
45
46/* Encrypt mailto: links */
47function UnCryptMailto(s){
48	var n = 0;
49	var r = "";
50	for( var i = 0; i < s.length; i++){
51		n = s.charCodeAt( i );
52		if( n >= 8364 ){
53			n = 128;
54		}
55		r += String.fromCharCode( n - 1 );
56	}
57	return r;
58}
59function linkTo_UnCryptMailto(s){
60	location.href=UnCryptMailto(s);
61}
62
63$(document).ready(function() {
64
65	$('#scroll-highlights').click(function(){
66		scroll_to_shop();
67	});
68	$('.header-drop span, .header-drop img').click(function(){
69		if ($(".header-drop").hasClass("mobile-drop")) {
70			scroll_to_shop();
71		}
72	});
73
74	//Toggle navigation for mobile devices
75	$('.wrap-mobile-nav-btn').click(function() {
76		toggle_nav();
77	});
78
79	//Close navigation for mobile devices
80	$('#nav-hide').click(function() {
81		toggle_nav();
82	});
83
84
85	//Toggle subnavigation on mobile devices
86	$('.nav-left-selected').click(function() {
87		toggle_subnavigation( $(this).next('.mobile-subnav-btn') );
88	});
89
90	$('.mobile-subnav-btn').click(function() {
91		toggle_subnavigation($(this));
92	});
93	$('.mobile-sub-subnav-btn').click(function() {
94		toggle_subnavigation($(this));
95	});
96
97	//On first menu level open at first subnavigation on mobile devices
98	$('.nav-left').click(function() {
99
100		var nav_lang = ($(this).parent().parent().parent().attr('class') == "wrap-language-nav") ? true : false;
101
102		if(nav_lang == true){
103			toggle_subnavigation($(this).parent().find('.mobile-subnav-btn'));
104			return false;
105		}else{
106
107			if($('.wrap-body').css('min-width') != '1240px' && $(this).parent().find('.mobile-subnav-btn').length > 0 ){
108
109				var obj_btn = $(this).parent().find('.mobile-subnav-btn');
110
111				//Get action
112				var action = (obj_btn.css('background-position') == '0px 0px') ? 'open' : 'close';
113				if(action == "open"){
114					toggle_subnavigation(obj_btn);
115					return false;
116				}else{
117					return true;
118				}
119			}else{
120				return true;
121			}
122		}
123	});
124
125	//On submenu level open at first subnavigation on mobile devices
126	$('.nav-left-sublevel').click(function() {
127		if($('.wrap-body').css('min-width') != '1240px' && $(this).parent().find('.mobile-sub-subnav-btn').length > 0 ){
128
129			var obj_btn = $(this).parent().find('.mobile-sub-subnav-btn');
130
131			//Get action
132			var action = (obj_btn.css('background-position') == '0px 0px') ? 'open' : 'close';
133			if(action == "open"){
134				toggle_subnavigation(obj_btn);
135				return false;
136			}else{
137				return true;
138			}
139		}else{
140			return true;
141		}
142	});
143
144	//Lens function for Galleries. css styles .plus, .minus must be defined separately. See index.php file
145	$(".wrap-rslides ul.plus li img, .image-info img").click(function(){
146
147		var imageWrapperClass = 'rslides';
148
149		if( $(this).parent().hasClass('image-info') ){
150			imageWrapperClass = 'image-info';
151		}
152
153		var parentContentContainer  = $(this).closest('.wrap-content');
154		var parentColContainer      = ""; //Ex. col-content-1
155		var parentRslidesContainer  = parentContentContainer.find('.' + imageWrapperClass);
156
157		if( parentRslidesContainer.hasClass('plus') && parentRslidesContainer.css('cursor') != "auto"){
158			//Toggle class
159			parentRslidesContainer.removeClass('plus').addClass('minus');
160
161			//Loop trough cols
162			for( i =  1; i <= 5; i++){
163
164				parentColContainer = parentContentContainer.find('.col-content-' + i);
165
166				if( parentColContainer.length ){
167					//Store initial base width
168					parentColContainer.data('baseWidth', parentColContainer[0].style.width);
169					//Set container width to 100%
170					parentColContainer.css({"width":"100%"});
171				}
172			}
173		}else if( parentRslidesContainer.css('cursor') != "auto" ){
174
175			parentRslidesContainer.removeClass('minus').addClass('plus');
176
177			for( i =  1; i <= 5; i++){
178
179				parentColContainer = parentContentContainer.find('.col-content-' + i);
180
181				if( parentColContainer.length ){
182					//Reset initial base width
183					parentColContainer.css('width', parentColContainer.data('baseWidth'));
184				}
185			}
186		}
187	});
188
189	//Show share content
190	$('.header-share-btn').click(function(){
191		$('.wrap-share-module').fadeIn();
192	});
193
194	//Close share content
195	$('.header-share-close-btn').click(function(){
196		$('.wrap-share-module').fadeOut();
197	});
198
199	//Show Google CSE and set focus
200	$('.search').click(function(e) {
201		e.preventDefault();
202		$('#search-frm').show();
203		$('.bar-header.animateIt').hide();
204		$('#search-frm').animate({top: '0px'}, 200, function(){
205			$('input.gsc-input').focus();
206		});
207
208	});
209
210	//Prevent internal links in iOS standalone web apps from opening in Mobile Safari
211	if (window.navigator.standalone) {
212		var local = document.domain;
213		$('a').click(function() {
214			var a = $(this).attr('href');
215			if ( a.match('http://' + local) || a.match('http://www.' + local) ){
216				event.preventDefault();
217				document.location.href = a;
218			}
219		});
220	}
221
222	if( $('.wrap-main-nav-desktop').css('display') == 'block' ){
223		$('#wrap-navigation').scroll(function(){
224			if( $('#wrap-navigation').scrollTop() > 0){
225				$('.shop-nav-desktop').hide();
226			}else{
227				$('.shop-nav-desktop').show();
228			}
229		});
230	}
231
232	/* Language selector */
233	$('.dropdown-toggle, .language-selector span').click(function() {
234		$('.dropdown-menu').toggle();
235		$('.language-selector').toggleClass("open");
236		/*$('.dropdown-toggle div').toggleClass("active");*/
237	});
238	/* Language selector */
239
240
241	highlights_welcome_height();							//On welcome page ajust layer hight.
242	get_el_with();											//Save initial element wiidth
243	setContentBox();										//Adjust content area
244	set_navigation_background();
245	showSize();
246	mobile_drop();
247});
248
249$(window).resize(function() {
250	if( $("#xl-gallery").is(":visible") ){
251		$("#xl-gallery").backstretch("resize");
252	}else {
253		scroll_top();
254		highlights_welcome_height(); //Set highlight element height
255		showSize();
256		setContentBox(function () {
257		});							//Adjust content area
258		mobile_drop();
259		langSelPos();               //Language selector
260	}
261	if( $(".content-top-banner").is(":visible") ){
262		$(".content-top-banner").backstretch("resize");
263	}
264});
265
266function showSize() {
267	$('#size').html('WIDTH : '+$('.wrap-body').width());
268}
269
270
271//Save initial element width
272function get_el_with(){
273
274	var index = 0;
275
276	$('.wrap-content-cols-2').each(function(){
277		for(var i = 1; i < 3; i++){
278			$('.wrap-content-cols-2 .col-content-'+i).each(function(){
279				content_cols_2_with[index] = $(this)[0].style.width;
280				index++;
281			});
282		}
283	});
284
285	index = 0;
286	$('.wrap-content-cols-3').each(function(){
287		for(var i = 1; i < 4; i++){
288			$('.wrap-content-cols-3 .col-content-'+i).each(function(){
289				content_cols_3_with[index] = $(this)[0].style.width;
290				index++;
291			});
292		}
293	});
294
295	index = 0;
296	$('.wrap-content-cols-4').each(function(){
297		for(var i = 1; i < 5; i++){
298			$('.wrap-content-cols-4 .col-content-'+i).each(function(){
299				content_cols_4_with[index] = $(this)[0].style.width;
300				index++;
301			});
302		}
303	});
304
305	index = 0;
306	$('.wrap-content-cols-5').each(function(){
307		for(var i = 1; i < 6; i++){
308			$('.wrap-content-cols-5 .col-content-'+i).each(function(){
309				content_cols_5_with[index] = $(this)[0].style.width;
310				index++;
311			});
312		}
313	});
314}
315
316//Adjust content area
317var setContentBox = function(callback){
318
319	var windowWidth 	= $('.wrap-body').width();
320	var index = 0;
321
322	$('.wrap-content-cols-2').each(function(){
323		for(var i = 1; i < 3; i++){
324			$('.wrap-content-cols-2 .col-content-'+i).each(function(){
325				if(windowWidth <= 740){
326					$(this).css('width', '100%');
327				}else{
328					$(this).css('width', content_cols_2_with[index]);
329				}
330				index++;
331			});
332		}
333	});
334
335	index = 0;
336	$('.wrap-content-cols-3').each(function(){
337		for(var i = 1; i < 4; i++){
338			$('.wrap-content-cols-3 .col-content-'+i).each(function(){
339				if(windowWidth <= 800){
340					$(this).css('width', '100%');
341				}else{
342					$(this).css('width', content_cols_3_with[index]);
343				}
344				index++;
345			});
346		}
347	});
348
349	index = 0;
350	$('.wrap-content-cols-4').each(function(){
351		for(var i = 1; i < 5; i++){
352			$('.wrap-content-cols-4 .col-content-'+i).each(function(){
353				if(windowWidth <= 740){
354					$(this).css('width', '100%');
355				}else if(windowWidth > 740 && windowWidth < 800){
356					if(i == 1 || i == 3){
357						sum = parseInt(content_cols_4_with[index]) + parseInt(content_cols_4_with[index+1]);
358					}else{
359						sum = parseInt(content_cols_4_with[index]) + parseInt(content_cols_4_with[index-1]);
360					}
361
362					w = Math.floor(parseInt(content_cols_4_with[index])*100/sum*(100-sum)/100) + parseInt(content_cols_4_with[index]);
363					$(this).css('width', w + '%');
364
365				}else{
366					$(this).css('width', content_cols_4_with[index]);
367				}
368				index++;
369			});
370		}
371	});
372
373	index = 0;
374	$('.wrap-content-cols-5').each(function(){
375		for(var i = 1; i < 6; i++){
376			$('.wrap-content-cols-5 .col-content-'+i).each(function(){
377				if(windowWidth <= 800){
378					$(this).css('width', '100%');
379				}else{
380					$(this).css('width', content_cols_5_with[index]);
381				}
382				index++;
383			});
384		}
385	});
386
387	if(typeof callback == "function"){
388		callback();
389	}
390}
391
392//Toggle navigation
393function toggle_nav(){
394	$('.wrap-mobile-nav-btn,body').toggleClass('menu-down');
395
396	if ($("body").hasClass("menu-down")) {
397		setTimeout(function() {
398			langSelPos(); //Language selector
399		}, 500);
400	}
401
402	if($("#wrap-navigation").is(":visible")){
403		hide_nav(500);
404	}else{
405
406		var t = 60;
407
408		if( $('body').hasClass('down') != true ){
409
410			$('#nav-hide').show();
411
412			if( $('#mobile-indicator').is(':visible') ){
413
414				t = 60 - $(document).scrollTop();
415			}else{
416				t = 60 - $(document).scrollTop();
417			}
418
419			$('.wrap-navigation').css({'top': t + 'px'});
420
421		}else{
422
423			$('#nav-hide').hide();
424
425			if( $('#mobile-indicator').is(':visible') === false){
426				t = 60;
427			}
428
429			$('.wrap-navigation').css({'top': t + 'px'});
430		}
431
432		show_nav(500);
433	}
434}
435
436//Hide navigation
437function hide_nav(speed){
438
439	$('.wrap-mobile-nav-btn').css({'background-position': '0 0px'});
440
441	$('.wrap-left-nav-level2').css({'overflow':'hidden', 'white-space': 'nowrap'});
442	$('.left-nav-level2-bgcolor').css({'overflow':'hidden', 'white-space': 'nowrap'});
443	$('.wrap-left-nav-level3').css({'overflow':'hidden', 'white-space': 'nowrap'});
444	$('.left-nav-level3-bgcolor').css({'overflow':'hidden', 'white-space': 'nowrap'});
445
446	if( $('#mobile-indicator').is(':visible') ){
447		$('html, body').css({'overflow':''});
448		$('body').removeClass('clown');
449		$('.bar-header.animateIt').css({'transition':'none'});
450		$('html, body').animate({
451			// scrollTop: $currentScrollPos
452		}, 1);
453		setTimeout(function() {
454			$('.bar-header.animateIt').css({'transition':' .1s top cubic-bezier(.3, .73, .3, .74)'});
455
456		}, 500);
457		$('#wrap-live-module').show();
458		$("#highlights-welcome").backstretch("resize");
459		$currentScrollPos = 0;
460	}else{
461		$('body').css({'overflow':''});
462	}
463
464	$('#wrap-navigation').animate({width: '0px'}, speed, function(){
465		$(this).hide();
466		//$('#bar-header-clone').hide();
467
468		$("#highlights-welcome").backstretch("resize");
469	});
470}
471
472//Show navigation
473function show_nav(speed){
474
475	$('.wrap-mobile-nav-btn').css({'background-position': '0 70px'});
476
477	var w = '100%';
478
479	if( $('#mobile-indicator').is(':visible') ){
480		w = '100%';
481	}
482
483	$('#wrap-navigation').css({'width':'0'});
484
485	$('#wrap-navigation').show().animate({width: w}, speed, function(){
486
487		if( $('#mobile-indicator').is(':visible') ){
488			$('#wrap-live-module').hide();
489			$("#highlights-welcome").backstretch("resize");
490
491			if( $('body').hasClass('down') == true ){
492				$('body').addClass('clown');
493				$currentScrollPos = $(document).scrollTop();
494				setTimeout(function() {
495					$('html, body').css({'overflow':'hidden'});
496
497				}, 500);
498			}else{
499				$('html, body').css({'overflow':'hidden'});
500			}
501
502		}else{
503			$(' body').css({'overflow':'hidden'});
504		}
505
506		$('.wrap-left-nav-level2').css({'overflow':'', 'white-space': ''});
507		$('.left-nav-level2-bgcolor').css({'overflow':'', 'white-space': ''});
508		$('.wrap-left-nav-level3').css({'overflow':'', 'white-space': ''});
509		$('.left-nav-level3-bgcolor').css({'overflow':'', 'white-space': ''});
510	});
511}
512
513
514
515function highlights_welcome_height(){
516
517	if($('#highlights-welcome-placeholder').length){
518
519		var sh = 0;
520
521		let bottom = parseFloat($('.welcome-slider').css('bottom'));
522		let height = parseFloat($('.wrap-slider-content').css('height'));
523
524		if (bottom < 0) {
525			sh = $('.slider').height() + (((bottom * -1)-height)*2);
526		}
527
528		var wh = $(window).height();
529		var hh =  wh - $('.bar-header').height() + sh;
530		$('#highlights-welcome-placeholder').css({'height':hh+'px'});
531		$("#highlights-welcome").backstretch("resize");
532
533		if( $('.video-background').length ) {
534			$('#highlights-welcome-placeholder').css({'height': ($('.video-background').height() + sh) - $('.bar-header').height() + 'px'});
535		}else{
536			var wh = $(window).height();
537			var hh =  wh - $('.bar-header').height() + sh;
538			$('#highlights-welcome-placeholder').css({'height':hh+'px'});
539			$("#highlights-welcome").backstretch("resize");
540		}
541	}
542}
543
544function animate_header(){
545
546	var h = $('.bar-header').height();
547
548	if( $(window).scrollTop() > h ){
549		$(".bar-header.animateIt").show();
550	}else{
551		$(".bar-header.animateIt").hide();
552	}
553
554	$("body").toggleClass("down", ($(window).scrollTop() > h));
555}
556
557function scroll_top() {
558	/*hide_nav(0);*/
559}
560
561var last_accessed_nav = new Array()
562
563//Toggle subnavigation on mobile devices
564function toggle_subnavigation(obj){
565
566
567	let el = obj.parent().find('div:first');
568	let classAttr = el.attr('class');
569
570	if (!classAttr) {
571		return; // Funktion abbrechen
572	}
573
574	let class_array  = classAttr.split(/\s+/);
575
576	class_array			= class_array[1].split('_');
577
578	var menu_level		= class_array[0];
579	var array_index		= menu_level;
580	var el_level 		= array_index;
581	el_level++;
582
583	//Remove background padding
584	unset_navigation_background();
585
586	//Get action
587	var action = (obj.css('background-position') == '0px 0px') ? 'open' : 'close';
588
589	//Array to loop trough elements
590	var nav_level_array = new Array("", "-margin");
591
592	//Close all previous opened menus
593	if(menu_level == 1){
594		$('.left-nav-level1-bg').css({'background-color':' transparent'});
595		$('.wrap-left-nav-level1-margin').css({'background-color':' transparent'});
596		$('.left-nav-level1-bg').css({'border-top':'0'});
597		$('.left-nav-level1-bg').css({'border-bottom':'0'});
598	}
599	for (var n=4; n>=1; n--) {
600		if( n>= menu_level ){
601			$('.left-nav-level'+n+'-bg .mobile-subnav-btn').css({'background-position':'0px 0px'});
602			$('.left-nav-level'+n+'-bg .mobile-sub-subnav-btn').css({'background-position':'0px 0px'});
603			$('.left-nav-level'+n+'-bg').css({'border-bottom':'0'});
604		}
605	}
606
607	for (var n=2; n<6; n++) {
608		for (var i=0; i<nav_level_array.length; i++) {
609			if(n>=el_level){
610				$('.wrap-left-nav-level' + n + nav_level_array[i]).each(function(i, obj) {
611					$(this).hide('fast', function(){});
612				});
613			}
614		}
615	}
616
617	//Switch image
618	if(action == "open"){
619		if(menu_level == 1){
620			obj.parent().parent().css({'background-color':'#ffffff'});
621			//obj.parent().parent().css({'border-top':'5px solid #ffffff'});
622		}
623		if(menu_level == 1){
624			obj.css({'background-position':'0px 74px'});
625		}else if(menu_level > 1){
626			obj.css({'background-position':'0px 61px'});
627		}
628	}else{
629		if(menu_level == 1){
630			obj.parent().css({'background-color':' transparent'});
631			obj.parent().parent().css({'background-color':' transparent'});
632		}
633		obj.css({'background-position':'0px 0px'});
634	}
635
636	for (var i=0; i<nav_level_array.length; i++) {
637
638		var l = $('.wrap-left-nav-level' + el_level + nav_level_array[i]).length;
639
640		$('.wrap-left-nav-level' + el_level + nav_level_array[i]).each(function(n, obj) {
641
642			var el_array = $(this).find('div:first').attr('class').split(/\s+/);
643
644			el_array = el_array[1].split('_');
645
646			if(class_array[array_index] == el_array[array_index]){
647
648				if(action == "open"){
649					$(this).slideDown('fast', function(){});
650					//Store last object to add background padding
651					ob = $(this);
652				}else{
653					$(this).hide('fast', function(){});
654				}
655			}
656			if(n == l - 1 && (typeof ob === "object") ){
657				//Add background padding to last object
658				ob.find('div:first').css({'border-bottom': '5px solid #ffffff'});
659			}
660		});
661
662
663	}
664
665	last_accessed_nav[0] = obj;
666	last_accessed_nav[1] = menu_level;
667
668}
669
670function set_navigation_background (){
671	if( $('.bgcolor').length > 1 ){
672		$('.bgcolor:first').css({'border-top' : '5px solid #ffffff'});
673		$('.bgcolor:last').css({'border-bottom' : '5px solid #ffffff'});
674	}
675}
676function unset_navigation_background (){
677	if( $('.bgcolor').length > 1 ){
678		$('.bgcolor:first').css({'border-top' : '0'});
679		$('.bgcolor:last').css({'border-bottom' : '0'});
680	}
681}
682function mobile_drop(){
683
684	var screenWidth = $(window).width();
685	$('.header-drop').css({'margin-right' : '0px'});
686
687	if(screenWidth < 767){
688		// alert("mobile");
689		$(".header-drop").addClass("mobile-drop");
690
691		if( $('#mobile-indicator').is(':visible') ){
692			/*$('.header-drop').css({'margin-right' : '-20px'});*/
693		}
694	} else {
695		$(".header-drop").removeClass("mobile-drop");
696	}
697}
698function scroll_to_shop(){
699
700	let h = 0;
701
702	if (!$('body').hasClass('content')) {
703
704		let bottom 	= parseFloat($('.welcome-slider').css('bottom'));
705		let height 	= parseFloat($('.wrap-slider-content').css('height'));
706		let sh 		= 0;
707
708		if (bottom < 0) {
709			sh = $('.slider').height() + (((bottom * -1)-height)*2);
710		}
711
712		h = $('#highlights-welcome').height() - 60 + sh - 30;
713	}
714
715	$('html, body').animate({
716		scrollTop:  h
717	}, 1000);
718
719}
720/* Language selector */
721function langSelPos(){
722	var l = 402;
723	if( $(".header-drop span").css("color") == "rgba(0, 0, 0, 0)" ){
724		l = 362;
725		if( $('#mobile-indicator').is(':visible') ){
726			l = 342;
727		}
728	}
729	var cW = $("body").prop("clientWidth") - l + "px";
730	$('.language-dropdown').css({"left":cW})
731}
732/* Language selector */

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.