PageSourceSearch

https://dommuseum.at/items/frontend/js/desktop.js?ver=1790940361

js dommuseum.at collected 2026-10-02 11:26:28 UTC 69,322 bytes, 2,745 lines download raw bytes

1// sameh code
2
3$(window).on('load', function () {
4	// setTimeout(function () {
5	// document.getElementById('loadingCanvas').style.display = 'none';
6	//document.getElementById('container').style.visibility = 'visible';
7	// }, 600);
8	// document.getElementsByClassName('slide')[0].style.visibility = 'visible';
9
10});
11
12$(document).ready(function () {
13	addListeners();
14});
15
16function addListeners() {
17	// cookies
18	$('#warning_close').click(function () {
19		$('#cookie_warning').fadeOut();
20		var $this = $(this);
21		$.ajax({
22			type: "POST",
23			url: rootUrl + "Frontend/saveCookie",
24			data: {},
25			success: function (data) {
26				$('#cookie_warning').fadeOut();
27			}
28		});
29	});
30
31
32	/* OLD newsletter handler (provider: ajabiz) - commented out on provider switch to Listmonk
33$('.module_newsletter_send').click(function(e){
34		e.preventDefault();
35		var $this = $(this);
36		var firstname = $(this).parent().find('input[name="firstName"]').val();
37		var lastname = $(this).parent().find('input[name="lastName"]').val();
38		var email = $(this).parent().find('input[name="email"]').val();
39
40
41		if(email != '' && lastname != '' && firstname != '')
42		{
43			$.ajax({
44				type: "POST",
45				url: rootUrl+'Frontend/subscribeNL',
46				data: {firstName: firstname, lastName: lastname, email: email},
47				success: function (data) {
48					var json = $.parseJSON(data);
49
50					$this.parent().parent().find('.module_error').text(json.msg);
51
52				}
53			});
54		}
55		else
56		{
57			$this.parent().parent().find('.module_error').text('Bitte alle Felder ausfüllen!');
58		}
59
60	});
61
62
63
64	*/
65
66	// NEW newsletter handler (provider: Listmonk) - sends email + name to Frontend/subscribeNL, which calls the Listmonk API.
67	$('.module_newsletter_send').click(function(e){
68		e.preventDefault();
69		var $this   = $(this);
70		var $module = $this.closest('.module_newsletter');
71		var name    = $.trim($this.closest('form').find('input[name="name"]').val());
72		var email   = $.trim($this.closest('form').find('input[name="email"]').val());
73		var emailRe = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
74
75		// Both fields are required.
76		if(name === '' || email === ''){
77			$module.find('.module_error').text(typeof nl_fill_all_string !== 'undefined' ? nl_fill_all_string : 'Bitte alle Felder ausfüllen!');
78			return;
79		}
80
81		// The e-mail field must contain a valid e-mail address.
82		if(!emailRe.test(email)){
83			$module.find('.module_error').text(typeof nl_invalid_email_string !== 'undefined' ? nl_invalid_email_string : 'Bitte geben Sie eine gültige E-Mail-Adresse ein.');
84			return;
85		}
86
87		// The name field must be a name, not an e-mail address.
88		if(name.indexOf('@') !== -1){
89			$module.find('.module_error').text(typeof nl_invalid_name_string !== 'undefined' ? nl_invalid_name_string : 'Bitte geben Sie Ihren Namen ein (keine E-Mail-Adresse).');
90			return;
91		}
92
93		$.ajax({
94			type: "POST",
95			url: rootUrl+'Frontend/subscribeNL',
96			data: {name: name, email: email},
97			success: function (data) {
98				var json = $.parseJSON(data);
99				$module.find('.module_error').text(json.msg);
100			}
101		});
102	});
103
104
105	$('.module_contact_send').click(function () {
106		var mid = $(this).attr('mid');
107		var $tnb_checkbox = $('#contact_form_' + mid + ' .tnb_checkbox');
108		if ($tnb_checkbox.length && !$tnb_checkbox.is(':checked')) {
109			$('.module_error[mid="' + mid + '"]').text(tnb_required_string);
110			return;
111		}
112		$(this).hide();
113		var $this = $(this).parent();
114		var mid = $(this).attr('mid');
115		var contact_email = $this.attr('contact_email');
116		var contact_title = $this.attr('contact_title');
117		var email_subject = $this.attr('email_subject');
118		var contact_email_text = $this.attr('contact_email_text');
119
120		var data = [], obj;
121		$('#contact_form_'+mid+' input').each(function(){
122		    obj = {};
123
124		    if(this.name == "newsletter")
125		    {
126		    	if($(this).is(":checked"))
127		    	{
128		    		obj["name"] = this.name;
129				    obj["value"] = this.value;
130				    obj["class"] =  this.className.replace("module_contact_input ", "");
131				    data.push(obj);
132		    	}
133
134		    }
135		    else
136		    {
137		    	obj["name"] = this.name;
138			    obj["value"] = this.value;
139			    obj["class"] =  this.className.replace("module_contact_input ", "");
140			    data.push(obj);
141		    }
142
143		});
144
145
146		$('#contact_form_'+mid+' textarea').each(function(){
147		    obj = {};
148
149
150		    	obj["name"] = this.placeholder;
151			    obj["value"] = this.value;
152			    obj["class"] =  "";
153			    data.push(obj);
154
155
156		});
157
158
159	//	var data = $('#contact_form_'+mid).serializeArray();
160		data.push({name: 'contact_email', value: contact_email, class: ''});
161		data.push({name: 'contact_title', value: contact_title,  class: ''});
162		data.push({name: 'contact_email_text', value: contact_email_text,  class: ''});
163		data.push({name: 'email_subject', value: email_subject,  class: ''});
164
165
166
167		if($('#contact_form_'+mid).find('.module_contact_input[type="email"]').length > 0 && $('#contact_form_'+mid).find('.module_contact_input[type="email"]').val() != '')
168		{
169			
170
171			 KROT.getSolution().then((solution) => {
172				
173					var cs = JSON.stringify(solution);
174					
175					
176					$.ajax({
177					type: "POST",
178					url: rootUrl + "Frontend/sendContact",
179					data: {data:data, captcha_at_solution: cs},
180					success: function (data) {
181						var json = $.parseJSON(data);
182						if (json.success) {
183							$('.module_error[mid="'+mid+'"]').text(json.message);
184							$(this).show();
185	
186							var firstname ='';
187							var lastname = '';
188							var email = '';
189							var send_nl = false;
190	
191							$.each(json.data, function(index,i){
192	
193								if(i.name == 'newsletter' && i.value == 1)
194								{
195									send_nl = true;
196								}
197	
198								if(i.name == 'Vorname' || i.name == 'Firstname')
199								{
200									firstname = i.value;
201								}
202	
203								if(i.name == 'Nachname' || i.name == 'Lastname')
204								{
205									lastname = i.value;
206								}
207	
208								if(i.name == 'Email')
209								{
210									email = i.value;
211								}
212							});
213	
214	
215							if(send_nl)
216							{
217	
218	
219								$.ajax({
220									type: "POST",
221									url: rootUrl+'Frontend/subscribeNL',
222									data: {firstName: firstname, lastName: lastname, email: $('#contact_form_'+mid).find('.module_contact_input[type="email"]').val()},
223									success: function (data) {
224										var json = $.parseJSON(data);
225	
226										//$this.parent().parent().find('.module_error').text(json.msg);
227	
228									}
229								});
230	
231							}
232	
233						}
234					}
235				});
236		});
237			
238			
239			
240			
241		}
242		else
243		{
244			$('.module_error[mid="'+mid+'"]').text('Bitte Felder ausfüllen!');
245			$(this).show();
246		}
247	});
248
249
250
251	$('.module_tour_send').click(function () {
252		var $this = $(this);
253		var lang = $(this).attr('lang');
254		var sid = $(this).attr('sid');
255		var $tnb_checkbox = $('.signup_form_' + sid + ' .tnb_checkbox');
256		if ($tnb_checkbox.length && !$tnb_checkbox.is(':checked')) {
257			$('.signup_form_' + sid).parent().find('.module_error').text(tnb_required_string);
258			return;
259		}
260		var mid = $(this).attr('mid');
261		var limit = $(this).attr('limit');
262		var is_limited = $(this).attr('limited');
263		var max = $(this).attr('max_ppl');
264		var current_num = $(this).attr('num_ppl');
265		var persons = $('.signup_form_' + sid).find('input[name="tour_num_person"]').val();
266		var ppl = $('.signup_form_' + sid).find('input[name="tour_num_people"]').val();
267		var children = $('.signup_form_' + sid).find('input[name="tour_num_children"]').val();
268		var children_3 = $('.signup_form_' + sid).find('input[name="tour_num_children_3"]').val();
269		var children_7 = $('.signup_form_' + sid).find('input[name="tour_num_children_7"]').val();
270		var children_11 = $('.signup_form_' + sid).find('input[name="tour_num_children_11"]').val();
271
272		if(persons == '' || persons == undefined)
273		{
274			persons = 0;
275		}
276
277		if(ppl == '' || ppl == undefined)
278		{
279			ppl = 0;
280		}
281
282		if(children == '' || children == undefined)
283		{
284			children = 0;
285		}
286
287		if(children_3 == '' || children_3 == undefined)
288		{
289			children_3 = 0;
290		}
291
292		if(children_7 == '' || children_7 == undefined)
293		{
294			children_7 = 0;
295		}
296
297		if(children_11 == '' || children_11 == undefined)
298		{
299			children_11 = 0;
300		}
301		console.log(parseInt(persons)+" "+ parseInt(ppl)+" "+ parseInt(children)+" "+ parseInt(children_3) +" "+ parseInt(children_7)+" "+ parseInt(children_11))
302		var sum = parseInt(persons) + parseInt(ppl) + parseInt(children) + parseInt(children_3) + parseInt(children_7) + parseInt(children_11) ;
303		console.log(sum);
304		console.log(current_num)
305		if (sum > 0) {
306			if (sum > limit && max != 0) {
307				console.log('toomany ppl')
308				var text_msg = 'You can only register ' + limit + ' persons at once.';
309				if(lang == 0)
310				{
311					text_msg = 'Sie dürfen maximal ' + limit + ' Personen auf einmal anmelden.';
312				}
313
314				$('.signup_form_' + sid).parent().find('.module_error').text(text_msg);
315			} else if (sum + parseInt(current_num) > max && max != 0) {
316				console.log('limit reached')
317				var text_msg = 'Unfortunately this event has not enough space to accommodate all of you desired guests.';
318				if(lang == 0)
319				{
320					text_msg = 'Leider hat diese Veranstaltung nicht genügend Plätze für ihre gewünschte Buchung frei.';
321				}
322
323
324				$('.signup_form_' + sid).parent().find('.module_error').text(text_msg);
325			} else {
326				$(this).hide();
327				$('.signup_form_' + sid).parent().find('.module_error').text(please_wait_string).css({'color': 'red'});
328				$.ajax({
329					type: "POST",
330					url: rootUrl + "Frontend/saveSignup",
331					data: $('.signup_form_' + sid).serialize() + '&tour_id=' + mid,
332					success: function (data) {
333						var json = $.parseJSON(data);
334						if (json.success) {
335
336
337							if(json.nl == 1)
338							{
339								/*var first = json.data.name.substr(0,json.data.name.indexOf(' '));
340								var last =	json.data.name.substr(json.data.name.indexOf(' ')+1); */
341
342								var first = json.data.vorname;
343								var last =	json.data.nachname;
344								$.ajax({
345									type: "POST",
346									url: rootUrl+'Frontend/subscribeNL',
347									data: {firstName: first, lastName: last, email: json.data.email},
348									success: function (data) {
349										var json = $.parseJSON(data);
350
351										//$this.parent().parent().find('.module_error').text(json.msg);
352
353									}
354								});
355
356							}
357
358
359
360							$('.signup_form_' + sid).parent().find('.module_error').html(json.message).css({'color': 'red'});
361							//$('.signup_form_' + sid).parent().find('.remaining_places').text(json.remaining);
362							$('.signup_form_' + sid).parent().attr('max_ppl', json.remaining).css({'color': 'red'});
363							$('.signup_form_' + sid)[0].reset();
364							$('.signup_form_' + sid).remove();
365							if (!json.show) {
366								//	$('.signup_form_' + sid).parent().hide();
367								$('.signup_form_' + sid).parent().empty().text(json.full).css({'color': 'red'});
368							}
369						} else {
370							$('.signup_form_' + sid).parent().find('.module_error').html(json.message).css({'color': 'red'});
371							$this.show();
372						}
373
374					}
375				});
376			}
377		}
378
379
380	});
381
382
383	// main searching
384
385	$('#search_field').keypress(function (e) {
386		if (e.which == 13) {
387			var filter = $('#search_field').val();
388			var sf = $('#search_field');
389			var sfv = sf.val();
390			if (filter != "") {
391				sf.val(' ');
392				window.location.href = rootUrl + "search?text=" + filter;
393			}
394
395		}
396	});
397
398
399	// search icon click action
400	$('#search_icon').click(function () {
401		var sf = $('#search_field');
402		var sfv = sf.val();
403		var filter = sfv;
404		if (sfv == "" || sfv.trim() == "") {
405			sf.toggleClass("search_input_open");
406			if (sf.hasClass("search_input_open")) {
407				sf.focus();
408			} else {
409				sf.blur();
410			}
411		} else {
412			sf.val(' ');
413			window.location.href = rootUrl + "search?text=" + filter;
414
415		}
416	});
417
418
419		// search button click action
420		$('#search_button').click(function () {
421			var sf = $('#search_field');
422			var sfv = sf.val();
423			var filter = sfv;
424			sf.val(' ');
425			window.location.href = rootUrl + "search?text=" + filter;
426		});
427
428
429	$('#mobile_search_icon').click(function () {
430		var sf = $('#mobile_search_field');
431		var sfv = sf.val();
432		var filter = sfv;
433		if (sfv !== "" && sfv.trim() !== "") {
434			sf.val(' ');
435			window.location.href = rootUrl + "search?text=" + filter;
436		} else {
437			sf.focus();
438		}
439	});
440
441
442	// collection searching
443
444	$('#collection_search_field').keypress(function (e) {
445		if (e.which == 13) {
446			var filter = $('#collection_search_field').val();
447			var sf = $('#search_field');
448			var sfv = sf.val();
449			if (filter != "") {
450				sf.val(' ');
451				window.location.href = rootUrl + "collection_search?text=" + filter;
452			}
453
454		}
455	});
456
457
458	// collection search icon click action
459	$('#collection_search_icon').click(function () {
460		var sf = $('#collection_search_field');
461		var sfv = sf.val();
462		var filter = sfv;
463		if (sfv == "" || sfv.trim() == "") {
464			sf.toggleClass("search_input_open");
465			if (sf.hasClass("search_input_open")) {
466				sf.focus();
467			} else {
468				sf.blur();
469			}
470		} else {
471
472			window.location.href = rootUrl + "collection_search?text=" + filter;
473
474		}
475	});
476
477
478	// language
479	$('.lang_btn').click(function () {
480		if (!$(this).hasClass('noclick')) {
481			var lang = $(this).attr('lang');
482			window.location.href = rootUrl + "changeLanguage/" + lang;
483		}
484	});
485
486	// menu
487	$('.col_header').click(function () {
488		var this_sub_submenu = $(this).siblings(".sub_submenu_container");
489
490		var this_header = $(this)
491		var this_arrow = $(this).children(".sub_submenu_arrow");
492		if (this_sub_submenu.hasClass("sub_submenu_container_open")) {
493			this_sub_submenu.removeClass("sub_submenu_container_open");
494			this_header.removeClass("col_header_active");
495			this_arrow.removeClass("sub_submenu_arrow_open");
496		} else {
497			$(".sub_submenu_container").removeClass("sub_submenu_container_open");
498			$(".sub_submenu_arrow").removeClass("sub_submenu_arrow_open");
499			$(".col_header").removeClass("col_header_active");
500			this_sub_submenu.addClass("sub_submenu_container_open");
501			this_header.addClass("col_header_active");
502			this_arrow.addClass("sub_submenu_arrow_open");
503
504			// set focus on submenu
505			$(this).parent().find('.sub_submenu_container')[0].focus();
506			console.log($(this).parent().find('.sub_submenu_container')[0]);
507		}
508
509		// toggle aria pressed and aria label
510		var aria_pressed = $(this).attr('aria-pressed');
511		if (aria_pressed == "true") {
512			$(this).attr('aria-pressed', 'false');
513		} else {
514			$(this).attr('aria-pressed', 'true');
515		}
516	});
517
518
519	// small screen
520	$("#mobile_menu_background").hide();
521	if ($(window).width() < 1050) {
522		$(".slider_menu_item_text").hide();
523		$(".dot").css('display', 'inline-block');
524
525	};
526	$(window).resize(function () {
527		if ($(window).width() > 1050) {
528			// set_interval = setInterval(auto_slider_slide, 10000);
529			$("#mobile_menu_background").hide();
530			$("#nav_btn").removeClass('opend');
531			$("#overflow_bug_container").removeClass('overflow_bug_container');
532			$("#nav_left").removeClass("logo_black_important_mobile");
533			$("#logo_text").removeClass('mobile_black_important');
534			$("#logo_sep").removeClass('hr_mobile_black_important');
535			$(".nav_btn_hr").removeClass('hr_mobile_black_important');
536
537
538
539			$(".dot").hide();
540			$(".slider_menu_item_text").css('display', 'inline-block');
541		};
542		if ($(window).width() < 1050) {
543			// set_interval = setInterval(auto_slider_slide, 10000);
544			$("#logo_text , .menu_item , .lang_btn,#search_container").removeClass("black_important");
545			$("#nav_left").removeClass("logo_black_important");
546			$(".sub_menu_background").hide();
547			$(".dot").css('display', 'inline-block');
548			$(".slider_menu_item_text").hide();
549			$("#logo_sep,#lang_sep").removeClass('hr_black_important');
550			$(".nav_btn_hr").removeClass('hr_black_important');
551			$(".menu_item").removeClass("active");
552			social_menu_btns_ids.forEach(function (item) {
553				$("#" + item + "_social_item").removeClass("social_item_" + item +
554					"_black_important");
555			});
556
557		};
558	});
559
560
561	// when click on the mobile menu btn
562	var slide_index = 1;
563	$("#nav_btn").click(function toggle() {
564		// return;
565		// slide_index++
566		// if (slide_index % 2 != 0) {
567		// 	clearInterval(set_interval);
568
569		// } else {
570		// 	set_interval = setInterval(auto_slider_slide, 10000);
571		// }
572
573		$('body').toggleClass('overlayMenuOpen');
574		
575		// toggle aria pressed
576		var aria_pressed = $(this).attr('aria-pressed');
577		if (aria_pressed == "true") {
578			$(this).attr('aria-pressed', 'false');
579		} else {
580			$(this).attr('aria-pressed', 'true');
581		}
582
583		$(this).toggleClass('opend');
584		$("#overflow_bug_container").toggleClass('overflow_bug_container');
585		$("#mobile_menu_background").slideToggle();
586		$("#nav_left").toggleClass("logo_black_important_mobile");
587		$("#logo_text").toggleClass("logo_black_important_mobile");
588		$("#logo_sep").toggleClass("hr_mobile_black_important");
589		$(".nav_btn_hr").toggleClass("hr_mobile_black_important");
590
591		// if opened, focus on #main_menu_mobile
592		if ($(this).hasClass('opend')) {
593			$('#main_menu_mobile').focus();
594		}
595
596		// scroll to the top of #mobile_menu_background
597		$('#mobile_menu_background').scrollTop(0);
598	});
599
600
601
602
603
604
605	var colors = eval(theme_colors);
606
607	/*var slideIndex = 1;
608	showSlides(slideIndex);
609
610	// Next/previous controls
611	function plusSlides(n) {
612		showSlides(slideIndex = n + 1);
613	}
614	// menu tap select
615	function menuSelect(n) {
616		showSlides(slideIndex = n);
617	}
618
619	// auto slider
620	function auto_slider_slide() {
621		plusSlides(1);
622	}
623	var set_interval = setInterval(auto_slider_slide, 10000);
624	// clearInterval(set_interval);
625
626	$(".menu_item").click(function () {
627		clearInterval(set_interval);
628	});
629	$(".slider_menu_item").click(function () {
630		clearInterval(set_interval);
631	});
632	$(".sub_menu_close").click(function () {
633		set_interval = setInterval(auto_slider_slide, 10000);
634	});
635*/
636	function showSlides(n) {
637		return;
638		// $("#loadingCanvasContainer").removeClass("canvas_animation").addClass("canvas_animation");
639
640
641		var i;
642		var slides = document.getElementsByClassName("slide");
643		var slides_menu = document.getElementsByClassName("slider_menu_item");
644
645		var change_color = document.getElementsByClassName("change_color");
646		var logo_change_color = document.getElementsByClassName("logo_change_color");
647		var hr_change_color = document.getElementsByClassName("hr_change_color");
648		var fb_icon_change_color = document.getElementsByClassName("fb_icon_change_color");
649		var t_icon_change_color = document.getElementsByClassName("t_icon_change_color");
650		var yt_icon_change_color = document.getElementsByClassName("yt_icon_change_color");
651		var insta_icon_change_color = document.getElementsByClassName("insta_icon_change_color");
652
653		var arrow_change_color = document.getElementsByClassName("arrow_change_color");
654
655
656
657		if (n > slides.length) {
658			slideIndex = 1
659		}
660		if (n < 1) {
661			slideIndex = slides.length
662		}
663		for (i = 0; i < slides.length; i++) {
664
665
666			slides_menu[i].style.border = "none";
667			dot = $(slides_menu[i]).find(".dot");
668			$(dot).removeClass("hr_" + colors[i]);
669		}
670
671
672		next = slides[slideIndex]
673		current = slides[slideIndex - 1];
674		prev = slides[slideIndex - 2];
675		last_slide = slides[slides.length - 1]
676
677		if (slideIndex == 1) {
678			next = slides[slideIndex]
679			current = slides[slideIndex - 1]
680			prev = slides[slides.length - 1]
681		}
682		if (slideIndex == slides.length) {
683			next = slides[0]
684			current = slides[slideIndex - 1]
685			prev = slides[slideIndex - 2]
686		}
687		// current.style.display = "block";
688		var slider_exist = $("#slider_container").length;
689		if (slider_exist > 0) {
690			current.classList.remove("next_slide", "prev_slide");
691			current.classList.add("current_slide");
692			prev.classList.remove("next_slide", "current_slide");
693			prev.classList.add("prev_slide");
694			next.classList.remove("current_slide", "prev_slide");
695			next.classList.add("next_slide");
696
697
698
699
700
701
702			if ($(window).width() > 1050) {
703				slides_menu[slideIndex - 1].style.borderBottom = "2px solid";
704			} else {
705				dot = $(slides_menu[slideIndex - 1]).find(".dot");
706				$(dot).addClass("hr_" + colors[slideIndex - 1]);
707			};
708			$(window).resize(function () {
709				if ($(window).width() > 1050) {
710					slides_menu[slideIndex - 1].style.borderBottom = "2px solid";
711				} else {
712					dot = $(slides_menu[slideIndex - 1]).find(".dot");
713					$(dot).addClass("hr_" + colors[slideIndex - 1]);
714				};
715			});
716
717			//   changing the colors control
718			// text
719			/* REMOVED color change
720			for (j = 0; j < change_color.length; j++) {
721				for (i = 0; i < colors.length; i++) {
722					change_color[j].classList.remove(colors[i]);
723				}
724				change_color[j].classList.add(colors[slideIndex - 1]);
725			}
726			// logo
727			for (j = 0; j < logo_change_color.length; j++) {
728				for (i = 0; i < colors.length; i++) {
729					logo_change_color[j].classList.remove("logo_" + colors[i]);
730				}
731				logo_change_color[j].classList.add("logo_" + colors[slideIndex - 1]);
732			}
733			// hr
734			for (j = 0; j < hr_change_color.length; j++) {
735				for (i = 0; i < colors.length; i++) {
736					hr_change_color[j].classList.remove("hr_" + colors[i]);
737				}
738				hr_change_color[j].classList.add("hr_" + colors[slideIndex - 1]);
739			}
740			//icons
741			// TODO make the code smaller with a for loop throw the icon names
742			for (j = 0; j < fb_icon_change_color.length; j++) {
743				for (i = 0; i < colors.length; i++) {
744					fb_icon_change_color[j].classList.remove("social_item_fb_" + colors[i]);
745				}
746				fb_icon_change_color[j].classList.add("social_item_fb_" + colors[slideIndex - 1]);
747			}
748			for (j = 0; j < t_icon_change_color.length; j++) {
749				for (i = 0; i < colors.length; i++) {
750					t_icon_change_color[j].classList.remove("social_item_t_" + colors[i]);
751				}
752				t_icon_change_color[j].classList.add("social_item_t_" + colors[slideIndex - 1]);
753			}
754			for (j = 0; j < insta_icon_change_color.length; j++) {
755				for (i = 0; i < colors.length; i++) {
756					insta_icon_change_color[j].classList.remove("social_item_insta_" + colors[i]);
757				}
758				insta_icon_change_color[j].classList.add("social_item_insta_" + colors[slideIndex - 1]);
759			}
760
761			for (j = 0; j < yt_icon_change_color.length; j++) {
762				for (i = 0; i < colors.length; i++) {
763					yt_icon_change_color[j].classList.remove("social_item_yt_" + colors[i]);
764				}
765				yt_icon_change_color[j].classList.add("social_item_yt_" + colors[slideIndex - 1]);
766			}
767
768*/
769
770
771			// $(".prev").click(function () {
772			// 	plusSlides(-1);
773
774			// })
775			// $(".next").click(function () {
776			// 	plusSlides(1);
777			// })
778
779			// !safari 9 let problem
780
781			var slider_menu_item = document.getElementsByClassName("slider_menu_item");
782			// for (let index = 0; index < slides.length; index++) {
783			// 	slider_menu_item[index].addEventListener('click', function () {
784			// 		menuSelect(index+1);
785			// 	})
786			// }
787
788			slider_menu_item[0].addEventListener('click', function () {
789				menuSelect(0 + 1);
790			});
791
792
793
794			slider_menu_item[1].addEventListener('click', function () {
795				menuSelect(1 + 1);
796			});
797
798
799
800			slider_menu_item[2].addEventListener('click', function () {
801				menuSelect(2 + 1);
802			});
803
804			slider_menu_item[3].addEventListener('click', function () {
805				menuSelect(3 + 1);
806			});
807
808			slider_menu_item[4].addEventListener('click', function () {
809				menuSelect(4 + 1);
810			});
811		}
812
813	}
814
815	// tags link pre filter for sammlungen
816	var tags_exist = $("#tags_container").length;
817	var tags_array = [];
818	if (tags_exist > 0) {
819
820		var use_cookies = getCookie("cookie_warning");
821
822		var current_url = window.location.href;
823		current_tag = current_url.split("/");
824		current_tag = current_tag[current_tag.length - 1];
825
826		current_tag = current_tag.replace(/%C3%B6|%C3%BC|%C3%A4|%C3%84|%C3%96|%C3%9C|%20/g, "");
827		current_tag = current_tag.toLowerCase().replace(/[^a-zA-Z0-9]+/g, "");
828
829		var tags = $(".tag")
830		delete tags.selector;
831		Object.keys(tags).forEach(function (item) {
832			var tag = tags[item];
833
834			var pre_tad_id = tag.id
835			var tag_count = $("." + pre_tad_id).length
836
837
838
839			tag_text = tag.innerHTML;
840			if (tag_text) {
841				tag_text = tag_text.toLowerCase().replace(/[^a-zA-Z0-9]+/g, "");
842				tag_text = tag_text.replace(/öüäÄÖÜ/g, "");
843			}
844
845			if (tag_text == current_tag) {
846
847				setTimeout(function(){
848
849					if(!$("#" + pre_tad_id).hasClass('active'))
850					{
851						$("#" + pre_tad_id).click();
852					}
853			    },10);
854
855				/*$("#" + pre_tad_id).addClass("active");
856				tags_array.push(pre_tad_id);
857			*/
858				/*$(".collection_item").fadeOut(200);
859				var collection_items = $(".collection_item");
860				delete collection_items.selector;
861				Object.keys(collection_items).forEach(function (item) {
862					var collection_item = collection_items[item];
863					tags_array.forEach(function tag_class(tag_class) {
864						if ($(collection_item).hasClass(tag_class)) {
865							$(collection_item).fadeIn(200)
866						}
867					});
868				});*/
869			}
870			tag.innerHTML += "<span class='tag_count'>(" + tag_count + ")</span>";
871		});
872
873
874
875		// tags filter for sammlungen
876		$(".tag").click(function (e) {
877
878			// console.log(1);
879			if ($(this).hasClass("active")) {
880				$(this).removeClass("active");
881				var tag_id = $(this).attr('id');
882				var tag_remove = tags_array.indexOf(tag_id);
883				if (tag_remove > -1) {
884					tags_array.splice(tag_remove, 1);
885				}
886				if (tags_array === undefined || tags_array.length > 0) {
887					$(".collection_item").hide();
888					var collection_items = $(".collection_item");
889					delete collection_items.selector;
890					var tag_classes = "";
891
892					tags_array.forEach(function tag_class(tag_class) {
893						if (tag_class == tags_array.slice(-1)[0]) {
894							tag_classes += "." + tag_class
895						} else {
896							tag_classes += "." + tag_class
897						}
898					});
899
900					Object.keys(collection_items).forEach(function (item) {
901						var collection_item = collection_items[item];
902						tags_array.forEach(function tag_class(tag_class) {
903							if ($(collection_item).hasClass(tag_class)) {
904								$(collection_item).fadeIn(10)
905							}
906						});
907					});
908				} else {
909					$(".collection_item").fadeIn(200);
910				}
911				if (use_cookies == 1) {
912
913					document.cookie = "active_tags = " + tags_array + "; path=/;";
914				}
915			} else {
916				// $(this).addClass("active");
917				activate_tag($(this));
918			}
919		})
920
921		// remember where I was .. reactivate tags
922
923		active_tags = getCookie('active_tags');
924		active_tags = active_tags.split(",");
925
926		remember_activate_tag(active_tags);
927
928
929		// mobile tags
930		$("#collection_tags_mobile_btn").click(function() {
931			$("#collection_tags_mobile").toggleClass("active");
932		})
933
934
935
936
937	}; //end if tags exist
938
939	function activate_tag(thiss) {
940		thiss.addClass("active");
941		var tag_id = thiss.attr('id');
942		tags_array.push(tag_id);
943		$(".collection_item").fadeOut(200);
944		var collection_items = $(".collection_item");
945		delete collection_items.selector;
946		var tag_classes = "";
947		tags_array.forEach(function tag_class(tag_class) {
948			if (tag_class == tags_array.slice(-1)[0]) {
949				tag_classes += "." + tag_class
950			} else {
951				tag_classes += "." + tag_class
952			}
953		});
954
955		Object.keys(collection_items).forEach(function (item) {
956			var collection_item = collection_items[item];
957			tags_array.forEach(function tag_class(tag_class) {
958				if ($(collection_item).hasClass(tag_class)) {
959					$(collection_item).fadeIn(200)
960				}
961			});
962		});
963		if (use_cookies == 1) {
964
965			document.cookie = "active_tags = " + tags_array + ";path=/;";
966		}
967	}
968
969
970	function remember_activate_tag(tags_array) {
971
972		$(".collection_item").fadeOut(200);
973		var collection_items = $(".collection_item");
974		delete collection_items.selector;
975		var tag_classes = "";
976		tags_array.forEach(function tag_class(tag_class) {
977			$("#" + tag_class).addClass("active");
978
979			if (tag_class == tags_array.slice(-1)[0]) {
980				tag_classes += "." + tag_class
981			} else {
982				tag_classes += "." + tag_class
983			}
984		});
985
986		Object.keys(collection_items).forEach(function (item) {
987			var collection_item = collection_items[item];
988			tags_array.forEach(function tag_class(tag_class) {
989				if ($(collection_item).hasClass(tag_class)) {
990					$(collection_item).fadeIn(200)
991				}
992			});
993		});
994
995		if (use_cookies == 1) {
996
997			document.cookie = "active_tags = " + tags_array + ";path=/;";
998		}
999	}
1000
1001
1002	function getCookie(cname) {
1003		var name = cname + "=";
1004		var decodedCookie = decodeURIComponent(document.cookie);
1005		var ca = decodedCookie.split(';');
1006		for (var i = 0; i < ca.length; i++) {
1007			var c = ca[i];
1008			while (c.charAt(0) == ' ') {
1009				c = c.substring(1);
1010			}
1011			if (c.indexOf(name) == 0) {
1012				return c.substring(name.length, c.length);
1013			}
1014		}
1015		return "";
1016	}
1017
1018
1019
1020
1021
1022
1023	// tags pre filter for calendar
1024	var calendar_tags_exist = $("#calendar_tags_container").length;
1025	var calendar_tags_array = [];
1026	if (calendar_tags_exist > 0) {
1027		var current_url = window.location.href;
1028		current_tag = current_url.split("/");
1029		current_tag = current_tag[current_tag.length - 1];
1030
1031		current_tag = current_tag.replace(/%C3%B6|%C3%BC|%C3%A4|%C3%84|%C3%96|%C3%9C|%20/g, "");
1032		current_tag = current_tag.toLowerCase().replace(/[^a-zA-Z0-9]+/g, "");
1033
1034		var tags = $(".tag")
1035		delete tags.selector;
1036		Object.keys(tags).forEach(function (item) {
1037			var tag = tags[item];
1038
1039			var pre_tag_id = tag.id
1040			tag_text = tag.innerHTML;
1041			if (tag_text) {
1042				tag_text = tag_text.toLowerCase().replace(/[^a-zA-Z0-9]+/g, "");
1043				tag_text = tag_text.replace(/öüäÄÖÜ/g, "");
1044			}
1045
1046			if (tag_text == current_tag) {
1047
1048
1049				$("#" + pre_tag_id).addClass("active");
1050				calendar_tags_array.push(pre_tag_id);
1051
1052				$(".category_list_item").fadeOut(200);
1053				$(".calendar_page_month_sep").fadeOut(200);
1054				$(".calendar_page_hr_sep").fadeOut(200);
1055
1056
1057				var category_list_items = $(".category_list_item");
1058				var calendar_page_month_seps = $(".calendar_page_month_sep");
1059				var calendar_page_hr_seps = $(".calendar_page_hr_sep");
1060
1061				delete category_list_items.selector;
1062				delete calendar_page_month_seps.selector;
1063				delete calendar_page_hr_seps.selector;
1064
1065				Object.keys(category_list_items).forEach(function (item) {
1066					var category_list_item = category_list_items[item];
1067					calendar_tags_array.forEach(function tag_class(calendar_tag_class) {
1068						if ($(category_list_item).hasClass(calendar_tag_class)) {
1069							$(category_list_item).fadeIn(200)
1070						}
1071					});
1072				});
1073
1074				Object.keys(calendar_page_month_seps).forEach(function (item) {
1075					var calendar_page_month_sep = calendar_page_month_seps[item];
1076					calendar_tags_array.forEach(function tag_class(calendar_tag_class) {
1077						if ($(calendar_page_month_sep).hasClass(calendar_tag_class)) {
1078							$(calendar_page_month_sep).fadeIn(200)
1079						}
1080					});
1081				});
1082
1083				Object.keys(calendar_page_hr_seps).forEach(function (item) {
1084					var calendar_page_hr_sep = calendar_page_hr_seps[item];
1085					calendar_tags_array.forEach(function tag_class(calendar_tag_class) {
1086						if ($(calendar_page_hr_sep).hasClass(calendar_tag_class)) {
1087							$(calendar_page_hr_sep).fadeIn(200)
1088						}
1089					});
1090				});
1091
1092
1093
1094			}
1095		});
1096	};
1097	// calendar switsh
1098	if ($("#calendar")) {
1099		$("#calendar").fadeOut();
1100		$("#calendar_switch").click(function () {
1101			$(this).toggleClass("active")
1102			$("#calendar").fadeToggle();
1103			$("#list_items_holder").fadeToggle();
1104			$("#calendar_tags_container").fadeToggle();
1105		});
1106
1107	}
1108
1109
1110	// tags filter for calendar
1111
1112	if (calendar_tags_exist > 0) {
1113		var calendar_tags_array = [];
1114		$(".tag").click(function () {
1115			if ($(this).hasClass("active")) {
1116				$(this).removeClass("active");
1117				var calendar_tag_id = $(this).attr('id');
1118				var calendar_tag_remove = calendar_tags_array.indexOf(calendar_tag_id);
1119				if (calendar_tag_remove > -1) {
1120					calendar_tags_array.splice(calendar_tag_remove, 1);
1121				}
1122				if (calendar_tags_array === undefined || calendar_tags_array.length > 0) {
1123
1124					$(".category_list_item").fadeOut(200);
1125					$(".calendar_page_month_sep").fadeOut(200);
1126					$(".calendar_page_hr_sep").fadeOut(200);
1127
1128
1129					var category_list_items = $(".category_list_item");
1130					var calendar_page_month_seps = $(".calendar_page_month_sep");
1131					var calendar_page_hr_seps = $(".calendar_page_hr_sep");
1132
1133
1134
1135					delete category_list_items.selector;
1136					delete calendar_page_month_seps.selector;
1137					delete calendar_page_hr_seps.selector;
1138
1139					var calendar_tag_classes = "";
1140					calendar_tags_array.forEach(function tag_class(calendar_tag_class) {
1141
1142						calendar_tag_classes += "." + calendar_tag_class
1143
1144					});
1145
1146					Object.keys(category_list_items).forEach(function (item) {
1147						var category_list_item = category_list_items[item];
1148						calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1149							if ($(category_list_item).hasClass(calendar_tag_class)) {
1150								$(category_list_item).fadeIn(200)
1151							}
1152						});
1153
1154					});
1155
1156					Object.keys(calendar_page_month_seps).forEach(function (item) {
1157						var calendar_page_month_sep = calendar_page_month_seps[item];
1158						calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1159							if ($(calendar_page_month_sep).hasClass(calendar_tag_class)) {
1160								$(calendar_page_month_sep).fadeIn(200)
1161							}
1162						});
1163					});
1164					Object.keys(calendar_page_hr_seps).forEach(function (item) {
1165						var calendar_page_hr_sep = calendar_page_hr_seps[item];
1166						calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1167							if ($(calendar_page_hr_sep).hasClass(calendar_tag_class)) {
1168								$(calendar_page_hr_sep).fadeIn(200)
1169							}
1170						});
1171					});
1172
1173				} else {
1174					$(".category_list_item").fadeIn(200);
1175					$(".calendar_page_month_sep").fadeIn(200);
1176					$(".calendar_page_hr_sep").fadeIn(200);
1177				}
1178			} else {
1179				$(this).addClass("active");
1180				var calendar_tag_id = $(this).attr('id');
1181				calendar_tags_array.push(calendar_tag_id);
1182
1183
1184				$(".category_list_item").fadeOut(200);
1185				$(".calendar_page_month_sep").fadeOut(200);
1186				$(".calendar_page_hr_sep").fadeOut(200);
1187
1188
1189
1190				var category_list_items = $(".category_list_item");
1191				var calendar_page_month_seps = $(".calendar_page_month_sep");
1192				var calendar_page_hr_seps = $(".calendar_page_hr_sep");
1193
1194
1195
1196				delete category_list_items.selector;
1197				delete calendar_page_month_seps.selector;
1198				delete calendar_page_hr_seps.selector;
1199
1200				var calendar_tag_classes = "";
1201
1202				calendar_tags_array.forEach(function tag_class(calendar_tag_class) {
1203					calendar_tag_classes += "." + calendar_tag_class
1204
1205				});
1206
1207				Object.keys(category_list_items).forEach(function (item) {
1208					var category_list_item = category_list_items[item];
1209					calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1210						if ($(category_list_item).hasClass(calendar_tag_class)) {
1211							$(category_list_item).fadeIn(200)
1212						}
1213					});
1214
1215				});
1216
1217				Object.keys(calendar_page_month_seps).forEach(function (item) {
1218					var calendar_page_month_sep = calendar_page_month_seps[item];
1219					calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1220						if ($(calendar_page_month_sep).hasClass(calendar_tag_class)) {
1221							$(calendar_page_month_sep).fadeIn(200)
1222						}
1223					});
1224				});
1225				Object.keys(calendar_page_hr_seps).forEach(function (item) {
1226					var calendar_page_hr_sep = calendar_page_hr_seps[item];
1227					calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1228						if ($(calendar_page_hr_sep).hasClass(calendar_tag_class)) {
1229							$(calendar_page_hr_sep).fadeIn(200)
1230						}
1231					});
1232				});
1233
1234
1235			}
1236		})
1237	};
1238}
1239
1240
1241
1242
1243// end sameh code
1244
1245var positions = [];
1246var highest_z = 1;
1247var fadeTime = 5000; //ms
1248var hidden_images = [];
1249
1250var mainTimer;
1251var detailTimer;
1252
1253// x = left, y = Top, z = Font size, w = width, h = height
1254var new_positions = [{
1255		x: 1100,
1256		y: 710,
1257		z: 46,
1258		w: 200,
1259		h: 200
1260	},
1261	{
1262		x: 20,
1263		y: 70,
1264		z: 20,
1265		w: 160,
1266		h: 200
1267	},
1268	{
1269		x: 530,
1270		y: 90,
1271		z: 26,
1272		w: 180,
1273		h: 210
1274	},
1275	{
1276		x: 1080,
1277		y: 100,
1278		z: 34,
1279		w: 200,
1280		h: 230
1281	},
1282	{
1283		x: 1650,
1284		y: 113,
1285		z: 26,
1286		w: 180,
1287		h: 210
1288	},
1289	{
1290		x: 2050,
1291		y: 100,
1292		z: 20,
1293		w: 160,
1294		h: 200
1295	},
1296	{
1297		x: 10,
1298		y: 775,
1299		z: 26,
1300		w: 160,
1301		h: 200
1302	},
1303	{
1304		x: 410,
1305		y: 732,
1306		z: 34,
1307		w: 200,
1308		h: 230
1309	},
1310	{
1311		x: 1570,
1312		y: 640,
1313		z: 34,
1314		w: 200,
1315		h: 230
1316	},
1317	{
1318		x: 2050,
1319		y: 690,
1320		z: 20,
1321		w: 170,
1322		h: 200
1323	},
1324	{
1325		x: 125,
1326		y: 1320,
1327		z: 24,
1328		w: 175,
1329		h: 205
1330	},
1331	{
1332		x: 630,
1333		y: 1370,
1334		z: 34,
1335		w: 225,
1336		h: 255
1337	},
1338	{
1339		x: 1260,
1340		y: 1400,
1341		z: 34,
1342		w: 185,
1343		h: 215
1344	},
1345	{
1346		x: 1930,
1347		y: 1178,
1348		z: 24,
1349		w: 175,
1350		h: 205
1351	},
1352	{
1353		x: 2530,
1354		y: 1578,
1355		z: 26,
1356		w: 175,
1357		h: 205
1358	},
1359
1360];
1361
1362
1363// $(document).ready(function()
1364// {
1365// 	generatePositions();
1366// 	addListeners();
1367// 	igniteDrag();
1368
1369// });
1370
1371/*
1372(function (global) {
1373
1374	if (typeof (global) === "undefined") {
1375		throw new Error("window is undefined");
1376	}
1377
1378	var _hash = "!";
1379	var noBackPlease = function () {
1380		global.location.href += "#";
1381
1382
1383		global.setTimeout(function () {
1384			global.location.href += "!";
1385		}, 50);
1386	};
1387
1388	global.onhashchange = function () {
1389		if (global.location.hash !== _hash) {
1390			global.location.hash = _hash;
1391		}
1392	};
1393
1394	global.onload = function () {
1395		noBackPlease();
1396
1397		// disables backspace on page except on input fields and textarea..
1398		document.body.onkeydown = function (e) {
1399			var elm = e.target.nodeName.toLowerCase();
1400			if (e.which === 8 && (elm !== 'input' && elm !== 'textarea')) {
1401				e.preventDefault();
1402			}
1403			// stopping event bubbling up the DOM tree..
1404			e.stopPropagation();
1405		};
1406	}
1407
1408})(window);*/
1409
1410
1411function tutorial(type) {
1412	if (type == "main") {
1413		mainTimer = setTimeout(function () {
1414
1415
1416			$('.tutorial_box.main').fadeIn();
1417
1418		}, fadeTime);
1419	} else {
1420
1421	}
1422}
1423
1424function ignitePackery() {
1425	/*$('#top10_inner').packery({
1426	  percentPosition: true
1427	});*/
1428}
1429
1430// Close the dropdown if the user clicks outside of it
1431$(window).on('click', function (event) {
1432	//if (!event.target.matches('.dropbtn') && !event.target.matches('.infobtn')) {
1433	if(!$(event.target).is('.dropbtn') && !$(event.target).is('.infobtn')){
1434		var dropdowns = $("dropdown-content");
1435		var i;
1436		for (i = 0; i < dropdowns.length; i++) {
1437			var openDropdown = dropdowns[i];
1438			if (openDropdown.classList.contains('show')) {
1439				openDropdown.classList.remove('show');
1440			}
1441		}
1442	}
1443});
1444
1445
1446
1447$(window).on('load', function () {
1448
1449	$('#preload').fadeOut();
1450	tutorial('main');
1451	var w = window.innerWidth;
1452	var h = window.innerHeight;
1453
1454	var nw = (w / 2) - 1250;
1455	var nh = (h / 2) - 900;
1456	$('#canvas').css({
1457		top: nh + "px",
1458		left: nw + "px"
1459	});
1460
1461	$.each($('.chapter'), function (i, item) {
1462		var $this = $(this);
1463		var image_positions = [];
1464		image_positions = generatePositionsArray(250, 200, 40, 10);
1465
1466		var randomSize = (Math.random() * (1.300 - 0.550) + 0.550).toFixed(4);
1467
1468
1469		$.each($this.find('.chapter_item'), function (x, iitem) {
1470
1471			var coords = getRandomPosition(image_positions);
1472
1473
1474			$(iitem).css({
1475				left: coords.x + "px",
1476				top: coords.y + "px"
1477			});
1478			$(iitem).attr('defaultX', coords.x);
1479			$(iitem).attr('defaultY', coords.y);
1480
1481		});
1482
1483	});
1484
1485	var image_positions_top10 = [];
1486	var tw = w * 0.84;
1487	var th = h * 0.88;
1488
1489	image_positions_top10 = generatePositionsArray(tw - 300, th - 300, 40, 10);
1490
1491
1492	$.each($('.top10_item'), function (i, item) {
1493		var $this = $(this);
1494
1495
1496		//var randomSize = (Math.random() * (1.300 - 0.550) + 0.550).toFixed(4);
1497
1498		var coords = getRandomPosition(image_positions_top10);
1499
1500
1501		$(item).css({
1502			left: coords.x + "px",
1503			top: coords.y + "px"
1504		});
1505		$(item).attr('defaultX', coords.x);
1506		$(item).attr('defaultY', coords.y);
1507
1508	});
1509
1510	$('.top10_item').draggable({});
1511
1512});
1513
1514
1515function calculateDistance(elem, mouseX, mouseY) {
1516	var dist = Math.floor(Math.sqrt(Math.pow(mouseX - (elem.offset().left + (elem.width() / 2)), 2) + Math.pow(mouseY - (elem.offset().top + (elem.height() / 2)), 2)));
1517	return dist;
1518}
1519
1520function calculateDistanceDrag(elem, mouseX, mouseY, offsetX, offsetY) {
1521	var dist = Math.floor(Math.sqrt(Math.pow(mouseX - (elem.offset().left + (elem.width() / 2) + offsetX), 2) + Math.pow(mouseY - (elem.offset().top + (elem.height() / 2) + offsetY), 2)));
1522
1523	return dist;
1524}
1525
1526function mobileMenuListeners() {
1527	$('#mobile_menu_btn').click(function () {
1528
1529		$(this).toggleClass('active');
1530
1531		if ($(this).hasClass('active')) {
1532			$(this).attr('src', rootUrl + 'items/frontend/img/icons_35x35_X.svg');
1533			$('#mobile_menu').fadeIn('fast');
1534		} else {
1535			$(this).attr('src', rootUrl + 'items/frontend/img/icons_35x35_menu.svg');
1536			$('#mobile_menu').fadeOut('fast');
1537		}
1538
1539	});
1540
1541	$('.mobile_menu_item.sub').click(function () {
1542
1543		$(this).next('.submenu_holder_mobile').slideToggle();
1544		$(this).toggleClass('active');
1545	});
1546}
1547
1548
1549// function addListeners()
1550// {
1551
1552// 	$(document).click(function(){
1553// 		$('.tutorial_box').fadeOut();
1554// 		clearTimeout(mainTimer);
1555// 		clearTimeout(detailTimer);
1556// 	});
1557
1558// 	$('#top10_btn').click(function(){
1559// 		$('#top10_holder').show();
1560// 		$('.dropbtn').click();
1561
1562// 		//ignitePackery();
1563// 		$('.top10_item').dragMomentum();
1564// 	});
1565
1566// 	$('#popup_close').click(function(){
1567
1568// 		$('#vote_popup_holder').hide();
1569
1570// 	});
1571
1572// 	$('.lang_item').click(function(){
1573// 		if(!$(this).hasClass('noclick'))
1574// 		{
1575// 			var lang = $(this).attr('lang');
1576// 			window.location.href = rootUrl+"changeLanguage/"+lang;
1577// 		}
1578// 	});
1579
1580// 	$('.top10_item').click(function(){
1581// 		var pid = $(this).attr('pid');
1582
1583// 		$('.one_img[img_id="'+pid+'"]').parent().addClass('active').click();
1584
1585// 	});
1586
1587// 	$('.tw_share').click(function(e){
1588// 		var image_id = $(this).parent().parent().find('img').attr('img_id');
1589// 		tweetShare(image_id);
1590// 	});
1591
1592// 	$('#mail_share').click(function(e){
1593// 		var image_id = $(this).parent().parent().find('img').attr('img_id');
1594// 		mailShare(image_id);
1595// 	});
1596
1597// 	$('.mail_share').click(function(e){
1598// 		var image_id = $(this).parent().parent().find('img').attr('img_id');
1599// 		mailShare(image_id);
1600// 	});
1601
1602// 	$('#mail_share').on('mouseover',function(e){
1603// 		$(this).css({'fill': '#444'});
1604// 	});
1605
1606// 	$('#mail_share').on('mouseout',function(e){
1607// 		$(this).css({'fill': '#000'});
1608// 	});
1609
1610// 	$('.mail_share').on('mouseenter',function(e){
1611
1612// 		$(this).css({'fill': '#bbb'});
1613// 	});
1614
1615// 	$('.mail_share').on('mouseleave',function(e){
1616// 		$(this).css({'fill': '#fff'});
1617
1618// 	});
1619
1620
1621// 	$('.fb_share').click(function(e){
1622// 		var image_id = $(this).parent().parent().find('img').attr('img_id');
1623
1624
1625// 		$.ajax({
1626// 		   type: "POST",
1627// 		   url: rootUrl+"Frontend/images_detail",
1628// 		   data: { image_id: image_id },
1629// 		   success: function(data)
1630// 		   {
1631// 				var json = $.parseJSON(data);
1632// 		   		if(json.status == "success")
1633// 		   		{
1634
1635// 		   			facebookShareImage(json.image.fname,json.image.short_description,image_id);
1636// 		   		}
1637
1638// 			    else
1639// 			    {
1640
1641// 			    }
1642
1643
1644// 		   }
1645// 		});
1646
1647
1648
1649// 	});
1650
1651
1652// 	$('.likeb').click(function(e){
1653// 		e.stopImmediatePropagation();
1654// 		$('.tutorial_box').fadeOut();
1655// 		 var $this = $(this);
1656// 		 var image_id = $(this).parent().parent().find('img').attr('img_id');
1657
1658// 		 if(!$this.hasClass('liked'))
1659// 		 {
1660// 			$.ajax({
1661// 			   type: "POST",
1662// 			   url: rootUrl+"Frontend/addLike",
1663// 			   data: { image_id: image_id },
1664// 			   success: function(data)
1665// 			   {
1666// 					var json = $.parseJSON(data);
1667// 			   		if(json.status == "success")
1668// 			   		{
1669// 			   			$this.attr('src', 'items/frontend/img/Icons_40x40_heartvoted.svg');
1670// 			   			$this.removeClass('likeb').addClass('liked');
1671
1672// 			   			$image_like = $('.likeb[img_id="'+image_id+'"]');
1673// 			   			$image_like.attr('src', 'items/frontend/img/Icons_40x40_heartvoted.svg');
1674// 			   			$image_like.removeClass('likeb').addClass('liked');
1675
1676// 			   			var leftOff = $this.offset().left;
1677// 			   			var topOff = $this.offset().top;
1678
1679// 			   			$('#vote_popup_holder').css({left: leftOff-60, top: topOff-100}).show();
1680// 			   			setTimeout(function(){
1681// 				   			$('#vote_popup_holder').fadeOut();
1682// 			   			},5000) ;
1683// 			   		}
1684// 			   }
1685// 			 });
1686// 		 }
1687
1688//      });
1689
1690
1691// 	$('.menu_item').click(function(e){
1692// 		var chapter_id = $(this).attr('chapter_id');
1693// 		$('.chapter[cid="'+chapter_id+'"]').click();
1694// 		$('.dropbtn').click();
1695// 	});
1696
1697// 	$('.dropbtn').click(function(){
1698// 		$(this).toggleClass('active');
1699
1700// 		/*if($('.infobtn').hasClass('active'))
1701// 		{
1702// 			$('#infoDropdown').slideUp();
1703// 			$('.infobtn').removeClass('active');
1704// 		}*/
1705
1706// 		$('#listDropdown').slideToggle();
1707// 	});
1708
1709
1710// 	/*$('.infobtn').click(function(){
1711// 		$(this).toggleClass('active');
1712
1713// 		if($('.dropbtn').hasClass('active'))
1714// 		{
1715// 			$('#listDropdown').slideUp();
1716// 			$('.dropbtn').removeClass('active');
1717// 		}
1718
1719// 		$('#infoDropdown').slideToggle();
1720// 	});
1721// */
1722
1723
1724// 	$('.chapter_item').on('click', function(e){
1725// 		var item = $(this).children('img').attr('img_id');
1726// 		e.stopPropagation();
1727// 		//var item = $(this).attr('img_id');
1728// 		$('#vote_popup_holder').hide();
1729// 		if(!$(this).hasClass('dragging') && $(this).hasClass('active'))
1730// 		{
1731// 			$.ajax({
1732// 			   type: "POST",
1733// 			   url: rootUrl+"Frontend/images_detail",
1734// 			   data: { image_id: item },
1735// 			   success: function(data)
1736// 			   {
1737// 					var json = $.parseJSON(data);
1738// 			   		if(json.status == "success")
1739// 			   		{
1740
1741// 			   			$("#sammlung").empty().text(json.image.chaptername);
1742// 			   			$("#title_content").empty().text(json.image.short_description);
1743// 			   			$("#foto_content").empty().text(json.image.photographer);
1744// 			   			$("#jahr_content").empty().text(json.image.year);
1745// 			   			$("#ort_content").empty().text(json.image.place);
1746// 			   			$("#beschreibung_content").empty().text(json.image.description);
1747
1748// 			   			if(json.image.curatorial_content !== null && json.image.curatorial_content != '')
1749// 			   			{
1750// 			   				$("#kk_content").empty().text(json.image.curatorial_content).show();
1751// 			   				$("#kk_content_title").show();
1752// 			   			}
1753// 			   			else
1754// 			   			{
1755// 			   				$("#kk_content").empty().text(json.image.curatorial_content).hide();
1756// 			   				$("#kk_content_title").hide();
1757// 			   			}
1758
1759
1760// 			   			$("#detail_img").attr("src",rootUrl + "items/uploads/images/" + json.image.fname);
1761// 			   			$('#detail_img').attr('img_id', item);
1762// 			   			$('#detail_vote').attr('img_id', item);
1763// 			   			if(json.can_vote == 0)
1764// 			   			{
1765// 				   			$('#detail_vote').attr('src', rootUrl+'items/frontend/img/Icons_40x40_heartvoted.svg');
1766// 				   			$('#detail_vote').removeClass('likeb').addClass('liked');
1767// 			   			}
1768// 			   			else
1769// 			   			{
1770// 				   			$('#detail_vote').attr('src', rootUrl+'items/frontend/img/herz_s.svg');
1771// 				   			$('#detail_vote').removeClass('liked').addClass('likeb');
1772// 			   			}
1773
1774
1775// 			   			$("#overlay").fadeIn();
1776
1777
1778
1779
1780// 			   		}
1781
1782// 				    else
1783// 				    {
1784
1785// 				    }
1786
1787
1788// 			   }
1789// 			});
1790// 		}
1791// 		else
1792// 		{
1793// 			$(this).parent().click();
1794// 		}
1795// 	});
1796// 	var windowW = $(window).width();
1797// 	var windowH = $(window).height();
1798// 	var centerW = windowW/2;
1799// 	var centerH = windowH/2;
1800
1801// 	$.each($('.chapter'), function(i,item){
1802// 		var $this = $(this);
1803
1804// 		if($this.hasClass('centered'))
1805// 		{
1806// 			var coords = new_positions[0];
1807// 		}
1808// 		else
1809// 		{
1810// 			var coords = getRandomPosition(new_positions, true);
1811// 		}
1812
1813
1814
1815// 		$this.find('.chapter_title').css({'font-size': coords.z +'px'});
1816
1817// 		$this.find('.chapter_item').css({'max-width': coords.w +'px', 'max-height': coords.h +'px'});
1818
1819
1820
1821
1822// 		$this.attr('defaultX', coords.x);
1823// 		$this.attr('defaultY', coords.y);
1824// 		$this.attr('defaultW', coords.w);
1825// 		$this.attr('defaultH', coords.h);
1826
1827// 		var offX = coords.x - centerW;
1828// 		var offY = coords.y - centerH;
1829
1830
1831// 		if(offX < 0)
1832// 		{
1833// 			offX = offX * -1;
1834// 		}
1835
1836// 		if(offY < 0)
1837// 		{
1838// 			offY = offY * -1;
1839// 		}
1840
1841
1842// 		$this.css({left: coords.x+"px", top: coords.y+"px"});
1843
1844
1845// 		/*var distance = calculateDistance($(item), centerW, centerH);
1846// 		var diff = (distance/100);
1847
1848
1849// 		$this.css({'opacity': 1-(diff/10)});
1850// 		*/
1851
1852// 	});
1853
1854// 	$('.chapter_close').click(function(e){
1855
1856// 		$('#viewport').css('z-index', '100');
1857// 		$('.icons1').children('img').css('display', 'none');
1858// 		$('.mail_share').css('display', 'none');
1859// 		e.stopPropagation();
1860// 		var elem = $(this).parent();
1861// 		var x = elem.attr('defaultX');
1862// 		var y = elem.attr('defaultY');
1863// 		var w = elem.attr('defaultW');
1864// 		var h = elem.attr('defaultH');
1865// 		highest_z = 1;
1866// 		elem.find('.chapter_item').removeClass('active');
1867// 		$(this).hide();
1868// 		elem.css({'position': 'absolute', 'z-index': 100, 'background': 'none'});
1869// 		elem.stop().animate({left: x, top:y, width:300, height:300}, 300);
1870// 		elem.find('.chapter_title').css({'top': -22});
1871// 		elem.find('.chapter_item').draggable('destroy');
1872// 		elem.find('.logo').hide();
1873
1874
1875
1876// 		$.each(elem.find('.chapter_item'), function(x,iitem){
1877// 			var left = $(iitem).attr('defaultX');
1878// 			var top = $(iitem).attr('defaultY');
1879
1880
1881// 			$(iitem).stop().animate({'max-width': w, 'max-height': h, left: left, top: top, 'z-index': 0},300);
1882// 		});
1883
1884// 		addChapterListener();
1885// 		igniteDrag();
1886
1887// 	});
1888
1889// 	addChapterListener();
1890
1891// 	$('#info').click(function(){
1892// 		$("#info_overlay").fadeIn();
1893// 	});
1894
1895// 	$('.overlay_close').click(function(){
1896// 		$(this).parent().hide();
1897
1898// 	});
1899
1900// 	$('.upload_overlay_close').click(function(){
1901// 		$(this).parent().parent().fadeOut('100');
1902
1903// 	});
1904
1905// 	$('#upload_btn').click(function(){
1906// 		$('#image_upload_overlay').fadeIn('fast');
1907// 	});
1908
1909
1910// 	$('#image_input_dummy').click(function(){
1911// 		$('#image_input').click();
1912// 	});
1913
1914
1915// 	$('#save_image_btn').click(function(){
1916// 		var $this = $(this);
1917
1918// 		var uploadpath = '/hdgoe/Bildlandschaften/items/uploads/images';
1919// 		var xhr = new XMLHttpRequest();
1920// 		var fd = new FormData;
1921// 		var files = $('#image_input').prop('files');
1922
1923// 		fd.append('data', files[0]);
1924// 		fd.append('filename', files[0].name);
1925// 		fd.append('uploadpath', uploadpath);
1926
1927// 		xhr.addEventListener('load', function(e)
1928// 		{
1929// 			var ret = $.parseJSON(this.responseText);
1930
1931// 			if(ret.success)
1932// 			{
1933// 				$('input[name=fname]').val(ret.filename);
1934// 				/*var elem = '<img src="'+rootUrl + 'items/uploads/images/' + ret.filename+'"></img>';
1935// 				$('#image_input_dummy').hide();
1936// 				$('#image_holder').append(elem);*/
1937
1938// 				$.ajax({
1939// 				   type: "POST",
1940// 				   url: rootUrl+"Frontend/saveImage",
1941// 				   data: $('#image_form').serialize(),
1942// 				   success: function(data)
1943// 				   {
1944// 						var json = $.parseJSON(data);
1945// 				   		if(json.status == "success")
1946// 				   		{
1947// 				   			$('#upload_success').show();
1948// 				   			$this.hide();
1949// 				   			setTimeout(function(){
1950// 					   			$('#image_upload_overlay').hide();
1951// 					   			$('#image_form')[0].reset();
1952// 					   			$('#upload_step_2').hide();
1953// 					   			$('#upload_step_1').show();
1954// 					   			$('#upload_success').hide();
1955// 				   			},2000);
1956
1957// 				   			/*$('#image_holder').empty();
1958// 				   			$('#image_input_dummy').show();*/
1959// 				   		}
1960
1961// 					    else
1962// 					    {
1963
1964// 					    }
1965// 				   }
1966// 				});
1967
1968
1969
1970
1971// 			}
1972// 			else
1973// 			{
1974// 				alert('Error while uploading');
1975// 			}
1976// 	    });
1977
1978// 		xhr.open('post', rootUrl + 'Frontend/upload_image');
1979// 		xhr.send(fd);
1980
1981
1982
1983
1984// 		var $this = $(this);
1985
1986
1987// 	});
1988
1989// 	$('#weiter_image_btn').click(function(){
1990// 		var $this = $(this);
1991// 		$('#upload_error').hide();
1992// 		$('#save_image_btn').show();
1993// 		var can_continue = true;
1994
1995// 		if($('#image_input').val() == "" || $('#image_input').val() == " ")
1996// 		{
1997// 			can_continue = false;
1998// 		}
1999
2000
2001// 		if($('#upload_name').val() == "" || $('#upload_name').val() == " ")
2002// 		{
2003// 			can_continue = false;
2004// 		}
2005
2006// 		if($('#upload_email').val() == "" || $('#upload_email').val() == " ")
2007// 		{
2008// 			can_continue = false;
2009// 		}
2010
2011// 		if($('#upload_description').val() == "" || $('#upload_description').val() == " ")
2012// 		{
2013// 			can_continue = false;
2014// 		}
2015
2016
2017// 		if(!can_continue)
2018// 		{
2019// 			$('#upload_error').show();
2020// 		}
2021// 		else
2022// 		{
2023// 			$('#upload_step_1').hide();
2024// 			$('#upload_step_2').show();
2025// 		}
2026
2027
2028// 	});
2029
2030// 	$('#cancel_image_btn').click(function(){
2031// 		$('#upload_step_2').hide();
2032// 		$('#upload_step_1').show();
2033// 	});
2034
2035// 	$('#setup_submit').on('click', function(){
2036// 		var setup_id = $('#setup_number').val();
2037
2038// 		$.ajax({
2039// 		   type: "POST",
2040// 		   url: rootUrl+"Frontend/SaveSetup",
2041// 		   data: { setup_id : setup_id },
2042// 		   success: function(data)
2043// 		   {
2044// 				var json = $.parseJSON(data);
2045// 		   		if(json.status == "success")
2046// 		   		{
2047
2048// 		   				alert('Setup Successfully')
2049// 		   				window.location.href = rootUrl
2050
2051// 		   		}
2052
2053// 			    else
2054// 			    {
2055
2056// 			    }
2057
2058
2059// 		   }
2060// 		});
2061
2062// 	});
2063
2064// }
2065
2066
2067/*function addDetailViewListener(){
2068	$('.chapter_item').dblclick(function($itemId){
2069
2070
2071		   $data = array();
2072
2073		//get image data
2074	    $item = $this->cm->getPendingByID($itemId)->row();
2075
2076
2077		//move to accepted table
2078		$data = array('fname' => $item->fname,
2079					  'chapter_id' => $item->chapter_id,
2080					  'upload_date' => $item->upload_date,
2081					  'ip_address' => $item->ip_address,
2082					  'short_description' => $item->short_description,
2083					  'description' => $item->description,
2084					  'photographer' => $item->photographer,
2085					  'year' => $item->year,
2086					  'place' => $item->place,
2087					  'email' => $item->email,
2088					  'name' => $item->name);
2089		$this->cm->insertAcceptedImage($data);
2090
2091		//remove DB entry from pending_images
2092		$this->cm->deletePendingByID($itemId);
2093
2094	 $resbons= array('success'=>true);
2095
2096	 echo json_encode($resbons);
2097
2098
2099	}
2100
2101}*/
2102
2103
2104function addChapterListener() {
2105
2106	$('.chapter').click(function (e) {
2107
2108		var cid = $(this).attr('cid');
2109		$('.tutorial_box').fadeOut();
2110
2111		detailTimer = setTimeout(function () {
2112			$('.tutorial_box.detail').fadeIn();
2113		}, fadeTime);
2114
2115
2116		$("#upload_image_chapter").val(cid);
2117
2118		$('#viewport').css('z-index', '10000');
2119		$('#canvas').draggable('destroy');
2120
2121		var $this = $(this);
2122
2123		//$this.find('.chapter_item').children('img').css('width', '100%');
2124		$this.find('.chapter_item').addClass('active');
2125		var windowW = $(window).width();
2126		var windowH = $(window).height();
2127		var defaultW = $this.width();
2128		var defaultH = $this.height();
2129		var x = $this.attr('defaultX');
2130		var y = $this.attr('defaultY');
2131		var w = $this.attr('defaultW');
2132		var h = $this.attr('defaultH');
2133
2134
2135		var Wratio = (windowW / defaultW) * 0.8;
2136		var Hratio = (windowH / defaultH) * 0.8;
2137
2138		var movecanvasLeft = parseInt(windowW / 2) - parseInt(x) - parseInt(defaultW / 2);
2139		var movecanvasTop = parseInt(windowH / 2) - parseInt(y) - parseInt(defaultH / 2);
2140
2141		$('#canvas').stop().animate({
2142			left: movecanvasLeft,
2143			top: movecanvasTop
2144		}, 400, function () {
2145
2146			/*$.each($('.chapter'), function(i,item){
2147
2148				var distance = calculateDistance($(item), windowW/2, windowH/2);
2149				var diff = (distance/100);
2150
2151				$(item).css({'opacity': 1-(diff/10)});
2152			});
2153			*/
2154
2155			$this.css({
2156				'background': '#fff'
2157			});
2158			$this.find('.chapter_title').css({
2159				'top': 30
2160			});
2161			$this.css({
2162				'position': 'fixed',
2163				'z-index': 1000
2164			});
2165
2166			var last_left = 0;
2167			var last_top = 0;
2168
2169			$.each($this.find('.chapter_item'), function (x, iitem) {
2170				var left = $(iitem).attr('defaultX');
2171				var top = $(iitem).attr('defaultY');
2172
2173				var img_h = $(iitem).find('img').height();
2174				var img_w = $(iitem).find('img').width();
2175
2176				var maxW = 90 * Wratio;
2177				var maxH = 450 * Hratio;
2178
2179				if (img_h > img_w) {
2180					var maxW = 90 * Wratio;
2181					var maxH = 90 * Wratio;
2182				}
2183
2184
2185
2186
2187				$(iitem).stop().animate({
2188					'max-width': maxW,
2189					'max-height': maxH,
2190					left: left * Wratio,
2191					top: top * Hratio
2192				}, 300, function () {
2193
2194					var img_h = $(iitem).find('img').height();
2195					var img_w = $(iitem).find('img').width();
2196					if ($(iitem).css('display') != 'none') {
2197
2198						$(iitem).css({
2199							height: img_h
2200						});
2201
2202						if (x < 10) {
2203							last_left = (left * Wratio) + parseInt((img_w - 230));
2204							last_top = (top * Hratio) - parseInt(50);
2205
2206						}
2207
2208					}
2209
2210
2211				});
2212
2213
2214
2215				if ($(iitem).css('display') == 'none') {
2216					var iid = $(iitem).attr('iid');
2217
2218					hidden_images.push(iid);
2219
2220				}
2221
2222
2223			});
2224
2225			setTimeout(function () {
2226				$('#tutorial_like').css({
2227					left: last_left,
2228					top: last_top
2229				});
2230			}, 1000);
2231
2232
2233
2234
2235			$this.stop().animate({
2236				width: windowW,
2237				height: windowH,
2238				left: 0,
2239				top: 0,
2240				'opacity': 1
2241			}, function () {
2242				$this.find('.chapter_close').show();
2243				$this.find('.logo').show();
2244				$this.find('.icons1').children('img').fadeIn().css({
2245					'display': 'block'
2246				});
2247				$this.find('.mail_share').css('display', 'block');
2248				$this.find('.chapter_item').draggable({
2249
2250					// get the initial X and Y position when dragging starts
2251					start: function (event, ui) {
2252						xpos = ui.position.left;
2253						ypos = ui.position.top;
2254						highest_z++;
2255						event.preventDefault();
2256						$(this).addClass('dragging').css({
2257							'z-index': highest_z
2258						});
2259
2260
2261
2262					},
2263					// when dragging stops
2264					stop: function (event, ui) {
2265						// calculate the dragged distance, with the current X and Y position and the "xpos" and "ypos"
2266
2267						var xmove = ui.position.left - xpos;
2268						var ymove = ui.position.top - ypos;
2269						$(this).removeClass('dragging');
2270						event.preventDefault();
2271
2272
2273
2274					}
2275
2276
2277				});
2278				$this.find('.chapter_item').dragMomentum();
2279
2280
2281
2282
2283			});
2284
2285			$('.chapter').unbind('click');
2286
2287
2288
2289		});
2290
2291
2292
2293
2294
2295
2296	});
2297}
2298
2299function loadNextImage(current_elem, parent) {
2300	var current_id = current_elem.attr('iid');
2301
2302	var next = hidden_images[0];
2303
2304	var child = parent.find('.chapter_item[iid="' + parseInt(next) + '"]');
2305
2306	if (child.length > 0) {
2307
2308		var x = 1;
2309		var windowW = $(window).width();
2310		var windowH = $(window).height();
2311
2312		var elems = parent.find('.chapter_item');
2313		$.each(elems, function (i, item) {
2314			var zi = parseInt($(item).css('z-index'));
2315			if (zi > x) {
2316				x = zi;
2317			}
2318
2319			var Wratio = (windowW / 300) * 0.8;
2320			var Hratio = (windowH / 300) * 0.8;
2321
2322			var img_h = $(item).find('img').get(0).height;
2323			var img_w = $(item).find('img').get(0).width;
2324
2325			var maxW = 90 * Wratio;
2326			var maxH = 450 * Hratio;
2327
2328			if (img_h > img_w) {
2329				var maxW = 90 * Wratio;
2330				var maxH = 90 * Wratio;
2331			}
2332
2333
2334
2335			$(item).css({
2336				'z-index': zi + 1,
2337				'max-width': maxW,
2338				'max-height': maxH
2339			});
2340
2341
2342
2343
2344
2345		});
2346		var left = getRandomInt(windowW * 0.35, windowW * 0.50);
2347		var top = getRandomInt(windowH * 0.20, windowH * 0.35);
2348
2349
2350		highest_z++;
2351		child.fadeIn().css({
2352			'z-index': 1,
2353			left: left,
2354			top: top
2355		});
2356
2357		var img_h = child.find('img').height();
2358		var img_w = child.find('img').width();
2359		child.css({
2360			width: img_w,
2361			height: img_h
2362		});
2363
2364
2365		var img_h = child.find('img').height();
2366		var img_w = child.find('img').width();
2367		child.css({
2368			width: img_w,
2369			height: img_h
2370		});
2371
2372		hidden_images.shift();
2373	} else {
2374		if (parent.find('.chapter_item').length > 10) {
2375			var oldest_z = 1000;
2376			var oldest = 1;
2377
2378			parent.find('.chapter_item').each(function (i, item) {
2379
2380				if (parseInt($(item).css('z-index')) < oldest_z && parseInt($(item).css('z-index')) != 1) {
2381					oldest = $(item).attr('iid');
2382					oldest_z = parseInt($(item).css('z-index'));
2383				}
2384			});
2385
2386
2387
2388
2389			parent.find('.chapter_item[iid="' + parseInt(oldest) + '"]').css({
2390				'z-index': highest_z
2391			}).hide();
2392			hidden_images.push(oldest);
2393			loadNextImage(parent.find('.chapter_item[iid="' + parseInt(oldest) + '"]'), parent);
2394		}
2395
2396
2397	}
2398}
2399
2400
2401
2402
2403/***********************
2404 * RANDOM POS
2405 ************************/
2406// Returns a random integer between min (included) and max (excluded)
2407// Using Math.round() will give you a non-uniform distribution!
2408function getRandomInt(min, max) {
2409	return Math.floor(Math.random() * (max - min)) + min;
2410}
2411
2412// generate random positions
2413function generatePositionsArray(maxX, maxY, safeRadius, irregularity) {
2414	// declarations
2415	var positionsArray = [];
2416	var r, c;
2417	var rows;
2418	var columns;
2419	// count the amount of rows and columns
2420	rows = Math.floor(maxY / safeRadius);
2421	columns = Math.floor(maxX / safeRadius);
2422	// loop through rows
2423	for (r = 1; r <= rows; r += 1) {
2424		// loop through columns
2425		for (c = 1; c <= columns; c += 1) {
2426			// populate array with point object
2427			positionsArray.push({
2428				x: Math.round(maxX * c / columns) + getRandomInt(irregularity * -1, irregularity),
2429				y: Math.round(maxY * r / rows) + getRandomInt(irregularity * -1, irregularity)
2430			});
2431		}
2432	}
2433	// return array
2434	return positionsArray;
2435}
2436
2437// get random position from positions array
2438function getRandomPosition(array, removeTaken) {
2439	// declarations
2440	var randomIndex;
2441	var coordinates;
2442	// get random index
2443	randomIndex = getRandomInt(1, array.length - 1);
2444	// get random item from array
2445	coordinates = array[randomIndex];
2446	// check if remove taken
2447	if (removeTaken) {
2448		// remove element from array
2449		array.splice(randomIndex, 1);
2450	}
2451	// return position
2452	return coordinates;
2453}
2454
2455function generatePositions() {
2456	positions = generatePositionsArray(canvasWidth - 400, canvasHeight - 400, 320, 10);
2457}
2458
2459
2460
2461
2462
2463
2464
2465/******************************************************************************************************************************************************************************************************
2466 * DRAGGING
2467 *****************************************************************************************************************************************************************************************************/
2468function igniteDrag() {
2469	$('#canvas').draggable({
2470		start: draggingStart,
2471		stop: draggingStop,
2472		drag: draggingDrag,
2473	});
2474}
2475
2476function draggingStart(event, ui) {
2477	dragging = true;
2478	$('.tutorial_box').fadeOut();
2479	clearTimeout(mainTimer);
2480	$('.chapter').unbind('click');
2481	if ($('.dropbtn').hasClass('active')) {
2482		$('.dropbtn').click();
2483	}
2484
2485
2486}
2487
2488function draggingStop(event, ui) {
2489
2490
2491	setTimeout(function () {
2492		dragging = false;
2493		addChapterListener();
2494
2495	}, 100);
2496}
2497
2498
2499function draggingDrag(event, ui) {
2500
2501	viewport_offset_x = ui.position.left;
2502	viewport_offset_y = ui.position.top;
2503	var screenpos_x = (viewport_offset_x) + ($(window).width() / 2);
2504	var screenpos_y = (viewport_offset_y) + ($(window).height() / 2);
2505
2506
2507
2508	$('.chapter').each(function (i, item) {
2509		/*
2510		var distance = calculateDistanceDrag($(item), screenpos_x, screenpos_y, viewport_offset_x, viewport_offset_y);
2511		var diff = (distance/100)*0.9;
2512
2513		$(item).css({'opacity': 1-(diff/10)});*/
2514	});
2515
2516}
2517
2518function jumpToImage(img_id) {
2519	$('.chapter_item').find('img[img_id="' + img_id + '"]').parent().click();
2520}
2521
2522
2523function tweetShare(img_id) {
2524	var thisCorrectUrl = rootUrl + "detail/" + img_id;
2525	var text = "";
2526
2527	window.open(
2528		'https://twitter.com/share?url=' + encodeURIComponent(thisCorrectUrl) + '&text=' + text,
2529		'facebook-share-dialog',
2530		'width=626,height=436');
2531	return false;
2532}
2533
2534
2535function mailShare(img_id) {
2536	var thisCorrectUrl = rootUrl + "detail/" + img_id;
2537	var text = "";
2538
2539	var subject = 'HdGÖ Bildlandschaften';
2540	var emailBody = thisCorrectUrl;
2541	window.location = 'mailto:?subject=' + subject + '&body=' + emailBody;
2542
2543
2544
2545	return false;
2546}
2547
2548function facebookShareImage(fname, title, pid) {
2549	if (title == " ") {
2550		title = "Image from bildlandschaften.hdgoe.at";
2551	}
2552
2553	FB.ui({
2554			method: 'share_open_graph',
2555			action_type: 'og.shares',
2556			action_properties: JSON.stringify({
2557				object: {
2558					'og:url': rootUrl + "detail/" + pid,
2559					'og:title': title,
2560					'og:description': "See this image with all details on bildlandschaften.hdgoe.at",
2561					'og:image': rootUrl + "items/uploads/images/" + fname
2562				}
2563			})
2564		},
2565		function (response) {
2566			// Action after response
2567
2568		});
2569
2570}
2571
2572
2573function startImageTimer(elem) {
2574	/*var id = $(this).find('img').attr("img_id");
2575
2576    timeouts[id] = setTimeout(function(){
2577        $("#"+id).stop(true).animate({"opacity":"1"},1000);
2578    }, 100);*/
2579}
2580
2581
2582dragMoment = function () {
2583	var howMuch = 150; // change this for greater or lesser momentum
2584	var minDrift = 5; //  minimum drift after a drag move
2585
2586	var containerPadding = [10, 10, 10, 10]; // top, right, bottom, left
2587	//  how near an edge can we get before the spring-back motion happens?
2588	//  positive numbers give a "padding" to the container (or window),
2589	//  negative numbers allow the dragged div to slide some distance outside
2590
2591	var easeType = 'easeOutQuad';
2592
2593	//  The standard ease types are 'linear' and 'swing'
2594	//  jQuery UI includes the following:  'easeInQuad',
2595	//  'easeOutQuad',  'easeInOutQuad',  'easeInCubic',
2596	//  'easeOutCubic',  'easeInOutCubic',  'easeInQuart',
2597	//  'easeOutQuart',  'easeInOutQuart', 'easeInQuint',
2598	//  'easeOutQuint',  'easeInOutQuint',  'easeInSine',
2599	//  'easeOutSine',  'easeInOutSine',  'easeInExpo',
2600	//  'easeOutExpo',  'easeInOutExpo',  'easeInCirc',
2601	//  'easeOutCirc',  'easeInOutCirc',  'easeInElastic',
2602	//  'easeOutElastic',  'easeInOutElastic',  'easeInBack',
2603	//  'easeOutBack',  'easeInOutBack',  'easeInBounce',
2604	//  'easeOutBounce',  'easeInOutBounce'
2605	//  Also see this page for a great display of the easing types.
2606	//  http://jqueryui.com/demos/effect/#easing
2607
2608	//  No user options below this point.
2609
2610	var dXa = [0];
2611	var dYa = [0];
2612	var dTa = [0];
2613
2614	return {
2615		cPadding: containerPadding, // top, right, bottom, left
2616		bounds: {},
2617		uid: 'dragMoID_',
2618		uindex: 1,
2619
2620		setBounds: function (elemID, containment, bbWidth, bbHeight) {
2621			/* dragMoment.bounds[elemID] = [];
2622			 if (!containment) {  // make the window the container, calibrate the boundaries
2623			     var dokWidth= $(window).width();
2624			     var dokHeight = $(window).height();
2625			     dragMoment.bounds[elemID][0] = dragMoment.cPadding[0];
2626			     dragMoment.bounds[elemID][1] = parseInt( $(window).width() - ( dragMoment.cPadding[1] + bbWidth) );
2627			     dragMoment.bounds[elemID][2] = parseInt( $(window).height() - ( dragMoment.cPadding[2] + bbHeight) );
2628			     dragMoment.bounds[elemID][3] = dragMoment.cPadding[3];
2629			 } else {  // container was set, so calibrate the boundaries
2630			     var cOffset = $(containment).offset();
2631
2632			     var cWidth = $(containment).outerWidth();
2633			     var cHeight = $(containment).outerHeight();
2634			     var bTop = parseInt( cOffset.top + dragMoment.cPadding[0] );
2635			     var bRight = parseInt( (cOffset.left + cWidth) - (dragMoment.cPadding[1] + bbWidth) );
2636			     var bBottom = parseInt( (cOffset.top + cHeight) - (dragMoment.cPadding[2] + bbHeight) );
2637			     var bLeft = parseInt( cOffset.left + dragMoment.cPadding[3] );
2638			     dragMoment.bounds[elemID] = [bTop, bRight, bBottom, bLeft];
2639			     // turn off containment, it's now handled by the dragMomentum.
2640			     $('#'+elemID).draggable("option", 'containment', '' );
2641			 }*/
2642		},
2643
2644		start: function (elemId, Xa, Ya, Ta) {
2645			dXa[elemId] = Xa;
2646			dYa[elemId] = Ya;
2647			dTa[elemId] = Ta;
2648			$('#' + elemId).data('moveCheck', 1);
2649
2650			highest_z++;
2651			$('#' + elemId).addClass('dragging').css({
2652				'z-index': highest_z
2653			});
2654
2655			$('.tutorial_box').fadeOut();
2656			loadNextImage($('#' + elemId), $('#' + elemId).parent());
2657
2658		}
2658, // END dragMoment.start()
2659
2660		stop: function (elemId, Xb, Yb, Tb) {
2661			//  record X and Y position, and the time when user stopped dragging.
2662
2663			var Xa = dXa[elemId];
2664			var Ya = dYa[elemId];
2665			var Ta = dTa[elemId];
2666			var Xc = 0;
2667			var Yc = 0;
2668			/*  var boundaryTop = dragMoment.bounds[elemId][0];
2669            var boundaryRight = dragMoment.bounds[elemId][1];
2670            var boundaryBottom = dragMoment.bounds[elemId][2];
2671            var boundaryLeft = dragMoment.bounds[elemId][3];
2672    */
2673			var dDist = Math.sqrt(Math.pow(Xa - Xb, 2) + Math.pow(Ya - Yb, 2));
2674			var dTime = Tb - Ta;
2675			var dSpeed = dDist / dTime;
2676			dSpeed = Math.round(dSpeed * 100) / 100;
2677
2678			var distX = Math.abs(Xa - Xb);
2679			var distY = Math.abs(Ya - Yb);
2680
2681			var dVelX = (minDrift + (Math.round(distX * dSpeed * howMuch / (distX + distY))));
2682			var dVelY = (minDrift + (Math.round(distY * dSpeed * howMuch / (distX + distY))));
2683
2684			var position = $('#' + elemId).position();
2685			var locX = position.left;
2686			var locY = position.top;
2687
2688			if (Xa > Xb) { // we are moving left
2689				Xc = locX - dVelX;
2690			} else { //  we are moving right
2691				Xc = locX + dVelX;
2692			}
2693
2694			if (Ya > Yb) { // we are moving up
2695				Yc = (locY - dVelY);
2696			} else { // we are moving down
2697				Yc = (locY + dVelY);
2698			}
2699			// Boundary Check
2700			/*   if (Xc < boundaryLeft ) { Xc = boundaryLeft }
2701			   if (Xc > boundaryRight ) { Xc = boundaryRight }
2702			   if (Yc < boundaryTop ) { Yc = boundaryTop }
2703			   if (Yc > boundaryBottom ) { Yc = boundaryBottom }
2704			   */
2705			var newLocX = Xc + 'px';
2706			var newLocY = Yc + 'px';
2707			$('#' + elemId).removeClass('dragging');
2708			$('#' + elemId).animate({
2709				left: newLocX,
2710				top: newLocY,
2711				useTranslate3d: true
2712			}, 500, easeType);
2713			startImageTimer($('#' + elemId));
2714
2715		} // END  dragMoment.stop()
2716	}; // END returned (public) functions
2717}(); // END dragMoment
2718
2719jQuery.fn.dragMomentum = function () {
2720	$(this).each(function () {
2721		$(this).css('position', 'absolute');
2722		if (!$(this).attr('id')) {
2723			// make sure the element has an ID, assign if necessary
2724			$(this).attr('id', (dragMoment.uid + dragMoment.uindex));
2725			dragMoment.uindex++;
2726		}
2727		var containment = $(this).draggable("option", 'containment');
2728		var bbWidth = $(this).outerWidth();
2729		var bbHeight = $(this).outerHeight();
2730		dragMoment.setBounds(this.id, containment, bbWidth, bbHeight);
2731
2732		var startOptions = function (e, ui) {
2733			dragMoment.start(this.id, e.clientX, e.clientY, e.timeStamp);
2734		};
2735		var stopOptions = function (e, ui) {
2736			dragMoment.stop(this.id, e.clientX, e.clientY, e.timeStamp);
2737			$(e.originalEvent.target).one('click', function (e) {
2738				e.stopImmediatePropagation();
2739			});
2740		};
2741		$(this).draggable("option", 'start', startOptions);
2742		$(this).draggable("option", 'stop', stopOptions);
2743	});
2744	return $(this);
2745} // END jquery .dragMomentum();

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.