// jQuery-Funktionen
$(document).ready(function(){
	
	// Dropdownmenü für deutsche Hauptnavigation
	$("ul.navi_main_de li.lvl1").hover(
		function(){
			$(this).addClass('lvl1_hover');
			$(this).find('a.lvl1').addClass('lvl1_hover');
		},
		function() {
			$(this).removeClass('lvl1_hover');
			$(this).find('a.lvl1').removeClass('lvl1_hover');
		} 
	);
	$("ul.navi_main_de li.lvl2").hover(
		function(){
			$(this).addClass('lvl2_hover');
			$(this).find('a.lvl2').addClass('lvl2_hover');
		},
		function() {
			$(this).removeClass('lvl2_hover');
			$(this).find('a.lvl2').removeClass('lvl2_hover');
		} 
	);
	
	
	// Sprachauswahl-Dropdown
	$("ul.sf-menu").superfish({
		autoArrows: false,
		dropShadows: false,
		speed: 'fast'
	});
	
	
	// Lightbox für Ticketinfo
	$("a#ticketinfo").fancybox({
		'hideOnContentClick': true,
		'overlayShow': true,
		'width': 700,
		'height': 550
	});
	
	// Lightbox für Video
	$("a#videobuttonlink").fancybox({
		'hideOnContentClick': true,
		'overlayShow': true,
		'width': 740,
		'height': 425
	});
	
	$("a#videobuttonlink_stadt").fancybox({
		'hideOnContentClick': true,
		'overlayShow': true,
		'width': 472,
		'height': 274
	});
	
	// Lightbox für 360°-Panorama
	$("#panoramabuttonlink").fancybox({
		'width': 1030,
		'height': 1030,
		'autoScale': false
	});
	
	
	// Preloader
	if(typeof(preloadImages)!=='undefined' && preloadImages!=null) {
		var imgCache = [];
		for(var idx=0, imgCount=preloadImages.length; idx<imgCount; ++idx) {
			var imgCached = document.createElement('img');
			imgCached.src = preloadImages[idx];
			imgCache.push(imgCached);
		}
	}
	
	// Accordion
	$('.accordion').accordion({ autoHeight: false, active: false, collapsible: true });
	$('.accordionhead').hover(
	  function () {
		$(this).addClass("hover");
	  },
	  function () {
		$(this).removeClass("hover");
	  }
	);
	
});


// Popup-Fenster
function popup(address, w, h) {
	showScrollbars = (popup.arguments.length>3) ? arguments[3] : 'yes';
	popup_options = 'width='+w+',height='+h+',location=no,resizable=no,scrollbars='+showScrollbars+',toolbar=yes,top=50,screenY=50,left=50,screenX=50';
	window.open(address, 'hallemsl', popup_options);
}

