/*################################################################################
	D E B U G
################################################################################*/


//  ################################################################################################################
// 	setFirstBackgroundImage()
//
//	First Image on the start site
//  ################################################################################################################

function setFirstBackgroundImage() {
	
	var defWidth	 	= 2048;
	var defHeight		= 1363;
	var defRatio		= defWidth / defHeight;
	var hgbCt			= $('backgroundContainer');
	var img				= $$('.backgroundContainerIMG1');
	
	
	hgbCt.style.width	= "0px";
	hgbCt.style.height	= "0px";
	
	var w				= document.body.offsetWidth;
	var h				= $(window).getSize().y;
	
	hgbCt.style.width	= w + "px";
	hgbCt.style.height	= h + "px";
	$('scrollContainer').setStyle('width', w);

	var tmpRatio = w / h;
	
	if(tmpRatio > defRatio) {
		img.setStyle('width', w + "px");
		img.setStyle('height', w/defRatio + "px");
		
	} else {
		img.setStyle('height', h + "px");
		img.setStyle('width', h * defRatio + "px");
	}
	img.setStyle('visibility', 'visible');
}


//################################################################################################################
//	setBackgroundImage()
//
//Fullscreen Hingergrundbilder
//################################################################################################################

function setBackgroundImage() {
	
	var defWidth	 	= 2048;
	var defHeight		= 1363;
	var defRatio		= defWidth / defHeight;
	var hgbCt			= $('backgroundContainer');
	var img				= $$('.backgroundContainerIMG');
	var scCt			= $$('.scrollContent');
	
	
	hgbCt.style.width	= "0px";
	hgbCt.style.height	= "0px";
	
	var w				= document.body.offsetWidth;
	var h				= $(window).getSize().y;
	
	hgbCt.style.width	= w + "px";
	hgbCt.style.height	= h + "px";
	$('scrollContainer').setStyle('width', w);

	var tmpRatio = w / h;
	
	if(tmpRatio > defRatio) {
		img.setStyle('width', w + "px");
		//scCt.setStyle('width', w);
		img.setStyle('height', w/defRatio + "px");
		//scCt.setStyle('height', h);
		if($('mediaplayer_wrapper') != null) {
			$('mediaplayer_wrapper').setStyle('width', w + "px");
			$('mediaplayer_wrapper').setStyle('height', w/defRatio + "px");
		}
		
	} else {
		img.setStyle('height', h + "px");
		//scCt.setStyle('width', w + "px");
		img.setStyle('width', h * defRatio + "px");
		//scCt.setStyle('height', h);
		if($('mediaplayer_wrapper') != null) {
			$('mediaplayer_wrapper').setStyle('height', h + "px");
			$('mediaplayer_wrapper').setStyle('width', h * defRatio + "px");
		}
	}
	img.setStyle('visibility', 'visible');
}


//################################################################################################################
//	setBackgroundImage1()
//
//Sets the image for the gallery slider module
//################################################################################################################

function setBackgroundImage1() {
	
	var defWidth	 	= 588;
	var defHeight		= 336;
	var defRatio		= defWidth / defHeight;
	var hgbCt			= $('aoi__articleGallery');
	var img				= $$('.sliderContainerIMG');
	var scCt			= $$('.scrollContent');
	
	
	hgbCt.style.width	= "588px";
	hgbCt.style.height	= "336px";
	
	var w				= document.body.offsetWidth;
	var h				= $(window).getSize().y;
	
	hgbCt.style.width	= 588 + "px";
	hgbCt.style.height	= 336 + "px";
	
	img.setStyle('visibility', 'visible');
}

//################################################################################################################
//setBackgroundImage1()
//
//Sets the image for the gallery slider module
//################################################################################################################

function setBackgroundVideo() {

var defWidth	 	= 588;
var defHeight		= 336;
var defRatio		= defWidth / defHeight;
var hgbCt			= $('aoi__articleGallery');
var img				= $$('.sliderContainerIMG');
var scCt			= $$('.scrollContent');


hgbCt.style.width	= "588px";
hgbCt.style.height	= "336px";

var w				= document.body.offsetWidth;
var h				= $(window).getSize().y;

hgbCt.style.width	= 588 + "px";
hgbCt.style.height	= 336 + "px";

img.setStyle('visibility', 'visible');
}

//  ################################################################################################################
// 	scaleImageContainers()
//
//	Passt die Grösse der Divs an, in denen sich die Moodseiten befinden
//  ################################################################################################################

function scaleMoodDivs() {
	var scCt			= $$('.scrollContent');
	var w				= $(window).getSize().x;
	var h				= $(window).getSize().y;
	
	scCt.each(function(moodLayer) {
		if(moodLayer.getSize().x !== 0) {
			moodLayer.setStyles({
				'width'		: w,
				'height'	: h
			
			});
		}
	});
}

//  ################################################################################################################
// 	setLogoPosition()
//
//	Positioniert das Logo in der Mitte des Bildschirms
//  ################################################################################################################

function setLogoPosition() {
	
	var screenWidth = $(window).getSize().x;
	var screehHeight = $(window).getSize().y;
	
	var xPosition = (screenWidth-850)/2
	var yPosition = (screehHeight-190)/2
	
	$('aoi__startLogo').setStyle('display','block');
	
	$('aoi__startLogo').setStyles({
		'top'	: yPosition,
		'left'	: xPosition
	});
}


//  ################################################################################################################
// 	swapBackgroundImages()
//
//	Wechsel der Hintergrundbilder
//  ################################################################################################################

function swapImages(page) {
	if(page == "start") {
		var ids			= $(document.body).getElements('div[id*=scrollContent]');
	} else {
		var ids			= $(document.body).getElements('div[id*=scrollGalleryContent]');
	}
	
	var divs		= ids.length-1;
	
	$('moodTotalRight').innerHTML = "/" + ids.length;
	$('moodTotalLeft').innerHTML = "/" + ids.length;
	
	$('actualMoodLeft').innerHTML = "1";
	$('actualMoodRight').innerHTML = "1";
	
	ids[0].setStyle('visibility','visible');
	
	$('nextMood').addEvent('click', function() {
		var found = false;
		
		ids.each(function(layer) {
			if(layer.getStyle('visibility')  == 'visible' && !found) {
				var activeLayer	= layer.id;
				var zIndex 		= $(activeLayer).getStyle('z-index');
				if($(activeLayer).getNext() != null) {
					var nextDIV		= $(activeLayer).getNext();
					var nextID		= nextDIV.id;
					$('actualMoodRight').innerHTML = parseInt($('actualMoodRight').innerHTML)+1;
					$('actualMoodLeft').innerHTML = parseInt($('actualMoodLeft').innerHTML)+1;
					
					$(activeLayer).tween('opacity', 0);
					$(activeLayer).setStyle('visibility','hidden');
					$(nextID).setStyle('visibility','visible');
					found = true;
				}
			}
		});
	});
	
	$('prevMood').addEvent('click', function() {
		var prevFound = false;
		
		ids.each(function(layer) {
			if(layer.getStyle('visibility')  == 'visible' && !prevFound) {
				var activeLayer	= layer.id;
				var zIndex 		= $(activeLayer).getStyle('z-index');
				if($(activeLayer).getPrevious() != null) {
					var prevDIV		= $(activeLayer).getPrevious();
					var prevID		= prevDIV.id;
					$('actualMoodRight').innerHTML = parseInt($('actualMoodRight').innerHTML)-1;
					$('actualMoodLeft').innerHTML = parseInt($('actualMoodLeft').innerHTML)-1;
					
					
					$(activeLayer).setStyle('visibility','hidden');
					$(prevID).setStyle('visibility','visible');
					$(prevID).tween('opacity', 1);
					prevFound = true;
				}
			}
		});
	});
	
}


//  ################################################################################################################
// 	scrollBackgroundImages()
//
//	Die FullscreenDIVs scrollen
//  ################################################################################################################

function scrollBackground() {
	var w		= $(window).getSize().x;
	var scCt	= $$('.scrollContent');
	var maxPos	= "-" + w*(scCt.length-1);
	
	$('rechts').addEvent('click', function() {
		var actualPosition 	= parseInt($('scrollContainer').getStyle('left'));
		var newPosition		= actualPosition-w;
		
		if(actualPosition != maxPos){
			$('scrollContainer').tween('left', newPosition)
		}
	});
	
	$('links').addEvent('click', function() {
		var actualPosition 	= parseInt($('scrollContainer').getStyle('left'));
		var newPosition		= actualPosition+w;
		
		if(actualPosition != 0){
			$('scrollContainer').tween('left', newPosition);
		}
	});
}


//  ################################################################################################################
// 	scrollMenu()
//
//	Die Subnavigation reagiert auf die Mauseposition -- erweitert mit iScroll für iOS
//  ################################################################################################################
var myiScroll;


screenWidth = 0;
firstHit 	= 0;

function getScreenWidth() {
	screenWidth = $(window).getSize().x;
	screehHeight = $(window).getSize().y;
}

function scrollMenu() {
	
	getScreenWidth();
	
	/* firsHit wird auf 1 gesetzt um die Initial Animation komplett abzuspielen
	bevor die Animation auf die Maus reagiert */
	firstHit = 1;
	
	/* Die Bildschirmbreite wird ausgelesen */
	var naviPosition = $(window).getSize().y-64;
	
	
	/* Die zu bewegende Navigation wird ermittelt. */
	var navi 	= $('subNaviDIV');
	
	
	/* Die Navigationspunkte werden gezählt damit die Scrolldistanz ausgerechnet werden kann */
	var items 	= navi.getElements('li[class*=item]');
	
	
	/* Die Subnavigation wird auf left:0px gestellt */
	navi.tween('left', 0);
	
	
	/* Die Navigationselemente werden gezählt und der Navicontainer entsprechned skaliert */
	navi.setStyle('width', (items.length*253)+42);
	
	
	/* Alle zur Berechnung/Animation notwendigen breiten werden gemessen und gespeichert */
	
	var contentWidth 	= parseInt(navi.getSize().x);
	
//	var distance100Percent	= parseInt((contentWidth - screenWidth));
	var distance1Percent	= (contentWidth - screenWidth)/100;

	var screen1Percent	= screenWidth/100;
	
	
	/* Animation bei Maus Bewegung */
	navi.addEvent('mousemove', function(event) {
		if(firstHit != 1) {
			
			
			var contentWidth 	= parseInt(navi.getSize().x);
//			var distance100Percent	= parseInt((contentWidth - screenWidth));
			var distance1Percent	= (contentWidth - screenWidth)/100;
			var screen1Percent	= screenWidth/100;
			
			var newLeftPosition = (event.page.x)/screen1Percent;
			navi.setStyle('left', '-' + newLeftPosition*distance1Percent + 'px');
		}
	});
	
	/* Positionierung beim ersten Rollover */
	navi.addEvent('mouseenter', function(event) {
		getScreenWidth();
		var distance1Percent	= (contentWidth - screenWidth)/100;
		var screen1Percent		= screenWidth/100;
		var newLeftPosition = (event.page.x)/screen1Percent;
		
		var myEffect = new Fx.Morph($(navi), {
			duration: '125',
			transition: 'sine:out',
			onComplete: function() { firstHit = 0 }
		});
		 
		myEffect.start({
			'left': '-' + newLeftPosition*distance1Percent + 'px'
		});
	});	
}


//  ################################################################################################################
// 	mainNavigationStauts()
//
//	Sorgt dafür, dass der angewählte Navipunkt seinen Status nicht verliert
//  ################################################################################################################

function mainNavigationStauts() {
	$$('.aoi_mainTrigger').each(function(naviNode) {
		naviNode.addEvent('mouseover', function(){
			$$('.aoi_mainTrigger').removeClass("over");
			$(this).addClass("over");
		});
	});
	$$('.aoi_mainTrigger').each(function(naviNode) {
		naviNode.addEvent('mouseout', function(){
			$(this).removeClass("over");
		});
	});
}


//  ################################################################################################################
// 	showSubNavigation()
//
//	Die Subnavgation wird hochgefahren
//  ################################################################################################################

function showSubNavigation() {
	
	$$('.aoi_mainTrigger').each(function(naviNode){
		var targetID	= naviNode.id + "DIV";
		naviNode.addEvent('mouseenter', function(){
			/*if($('backgroundContainer')) { 
				$$('.aoi__subNaviContainer').tween('bottom', -17);
				$(targetID).tween('bottom', 48);
				$('aoi__naviKiller').setStyles({
					'display': 'block',
					'bottom' : '128px'
				});
			}
			else if($('aoi__mainContainer')) { */
				if($(targetID) != null) {
					$$('.aoi__subNaviContainer_UP').tween('top', -24);
					$(targetID).tween('top', 48);
					$('aoi__naviKiller').setStyles({
						'display': 'block',
						'top' : '160px'
					});
				}
			/*}*/
		});
	});
	
	$('aoi__naviKiller').addEvent('mouseenter', function() {
		$$('.aoi__subNaviContainer_UP').tween('top', -24);
		$$('.aoi_mainTrigger').removeClass("over");
		$('aoi__naviKiller').setStyle('display', 'none');
	});
}


//  ################################################################################################################
// 	slideNavigation()
//
//	blendet die SlideNavigation der Startseite ein
//  ################################################################################################################

function fadeScrollButtons() {
	$('prevMood').tween('opacity', 0);
	$('nextMood').tween('opacity', 0);
}

function slideNavigation() {
	var screenHeight = $(window).getSize().y;
	var naviPosition = (screenHeight-140)/2;
	
	$('leftContainer').setStyle('height', screenHeight-128);
	$('rightContainer').setStyle('height', screenHeight);
	
	$('leftContainer').addEvent('mouseover', function() {
		$('prevMood').tween('opacity', 1);
		if($('aoi__startLogo') != null) {
			$('aoi__startLogo').fade('out');	
		}
	});
	
	$('leftContainer').addEvent('mouseout', function() {
		$('prevMood').tween('opacity', 0);	
		if($('aoi__startLogo') != null) {
			$('aoi__startLogo').fade('in');
		}
	});
	
	$('rightContainer').addEvent('mouseover', function() {
		$('nextMood').tween('opacity', 1);	
		if($('aoi__startLogo') != null) {
			$('aoi__startLogo').fade('out');
		}
	});
	
	$('rightContainer').addEvent('mouseout', function() {
		$('nextMood').tween('opacity', 0);
		if($('aoi__startLogo') != null) {
			$('aoi__startLogo').fade('in');	
		}
	});
	
	$('prevMood').setStyle('top', naviPosition);
	$('nextMood').setStyle('top', naviPosition);

};


function slideNavigationGallery() {
	
	$('leftGalleryContainer').addEvent('mouseover', function() {
		$('prevMood').tween('opacity', 1);
	});
	
	$('leftGalleryContainer').addEvent('mouseout', function() {
		$('prevMood').tween('opacity', 0);	
	});
	
	$('rightGalleryContainer').addEvent('mouseover', function() {
		$('nextMood').tween('opacity', 1);	
	});
	
	$('rightGalleryContainer').addEvent('mouseout', function() {
		$('nextMood').tween('opacity', 0);
	});
};


//  ################################################################################################################
// 	getTickets()
//
//	CSS3 Animation für die TicketIcons
//  ################################################################################################################

function getTicekts() {
	$('einzelticket').addEvent('mouseover', function() {
		$('aoi__einzelticket').addClass('over');
	});
	
	$('einzelticket').addEvent('mouseout', function() {
		$('aoi__einzelticket').removeClass('over');
	});
	
	$('gruppentickets').addEvent('mouseover', function() {
		$('aoi__gruppenticket1').addClass('over');
		$('aoi__gruppenticket2').addClass('over');
	});
	
	$('gruppentickets').addEvent('mouseout', function() {
		$('aoi__gruppenticket1').removeClass('over');
		$('aoi__gruppenticket2').removeClass('over');
	});
}

//  ################################################################################################################
// 	audioPlay()
//
//	Startet das Navigationsgeräusch
//  ################################################################################################################


function audioPlay() {
	$$('.aoi_mainTrigger').each(function(naviNode){
		var audioFile	=	naviNode.getNext('audio');
		//var audioFile	=	$('audio');
		naviNode.addEvent('mouseover', function() {
			audioFile.play();
		});
	});
}


//  ################################################################################################################
// 	eventScroller()
//
//	Scrollt durch die Übersicht der Events
//  ################################################################################################################

maxEvents = null
actualEvent = 0;

function eventScroller() {
	//alert('eventScroller wird geladen');
	maxEvents = $$('.aoi__calendarEvents').length-2;
	actualEvent = 1;
	
	var scroll = new Fx.Scroll('aoi__calendarContainer', {
		wait: false,
		duration: 1000,
		offset: {'x': 0, 'y': -15},
		transition: Fx.Transitions.Quad.easeInOut
	});
	
	$('aoi__scrollDown').addEvent('click', function(event) {
		if(actualEvent <= maxEvents) {
			event = new Event(event).stop();
			scroll.toElement('event' + (actualEvent+1));
			actualEvent++;
		}
	});
	
	$('aoi__scrollUp').addEvent('click', function(event) {
		if(actualEvent != 1) {
			event = new Event(event).stop();
			scroll.toElement('event' + (actualEvent-1));
			actualEvent--;
		}
	});
}


//  ################################################################################################################
// 	newsScroller()
//
//	Scrollt durch die Übersicht der News
//  ################################################################################################################

maxNews = null
actualNews = 0;

function newsScroller() {
	maxNews = $$('.aoi__newsTeaser').length-4;
	actualNews = 1;
	
	var scroll = new Fx.Scroll('aoi__newsOverview', {
		wait: false,
		duration: 1000,
		offset: {'x': 0, 'y': -4},
		transition: Fx.Transitions.Quad.easeInOut
	});
	
	$('aoi__scrollNewsDown').addEvent('click', function(event) {
		if(actualNews <= maxNews) {
			event = new Event(event).stop();
			scroll.toElement('news' + (actualNews+1));
			actualNews++;
			console.log(actualNews);
		}
	});
	
	$('aoi__scrollNewsUp').addEvent('click', function(event) {
		if(actualNews != 1) {
			event = new Event(event).stop();
			scroll.toElement('news' + (actualNews-1));
			actualNews--;
			console.log(actualNews);
		}
	});
}

//  ################################################################################################################
// 	newsCategoryScroller()
//
//	Scrollt durch die Übersicht der News
//  ################################################################################################################

maxNewsCat = null
actualNewsCat = 0;

function newsCategoryScroller() {
	maxNewsCat = $$('.aoi__newsTeaser').length-4;
	actualNewsCat = 1;
	
	var scroll = new Fx.Scroll('aoi__newsCategorySliderContainer', {
		wait: false,
		duration: 1000,
		offset: {'x': 0, 'y': -4},
		transition: Fx.Transitions.Quad.easeInOut
	});
	
	$('aoi__scrollnewsCatDown').addEvent('click', function(event) {
		if(actualNewsCat <= maxNewsCat) {
			event = new Event(event).stop();
			scroll.toElement('newsCat' + (actualNewsCat+1));
			actualNewsCat++;
		}
	});
	
	$('aoi__scrollnewsCatUp').addEvent('click', function(event) {
		if(actualNewsCat != 1) {
			event = new Event(event).stop();
			scroll.toElement('newsCat' + (actualNewsCat-1));
			actualNewsCat--;
		}
	});
}


//  ################################################################################################################
// 	hofScroller()
//
//	Scrollt durch die Übersicht der Hall of Fame
//  ################################################################################################################

maxHoF = null
actualHoF = 0;

function hofScroller() {
	maxHoF = $$('.aoi__hofSlider').length-4;
	actualHoF = 1;
	
	var scroll = new Fx.Scroll('aoi__hofSliderContainer', {
		wait: false,
		duration: 1000,
		offset: {'x': 0, 'y': 0},
		transition: Fx.Transitions.Quad.easeInOut
	});
	
	$('aoi__scrollHofDown').addEvent('click', function(event) {
		if(actualHoF <= maxHoF) {
			event = new Event(event).stop();
			scroll.toElement('hallOfFame' + (actualHoF+1));
			actualHoF++;
		}
	});
	
	$('aoi__scrollHofUp').addEvent('click', function(event) {
		if(actualHoF != 1) {
			event = new Event(event).stop();
			scroll.toElement('hallOfFame' + (actualHoF-1));
			actualHoF--;
		}
	});
}




//  ################################################################################################################
// 	galleryScroller()
//
//	Scroll Script für die Galerie-Übersichtsseite
//  ################################################################################################################

steps = 0;
		
function galleryScroller() {
	var pageNum = $$('.aoi__galleryScrollerContent').length-1;
	var maxSteps = pageNum;
	var imgNum = $$('.aoi__galleryScrollerContent').length;
	
	if(pageNum == 0) {
		$('aoi__galleryLeft').setStyle('display','none');
		$('aoi__galleryRight').setStyle('display','none');
	}
	
	$('aoi__galleryLeft').set('opacity',0.25);
	$('aoi__galleryLeft').setStyle('cursor','default');
	
	$('aoi__galleryScroller').setStyle('width', 672*imgNum + "px");
	
	$('aoi__galleryLeft').addEvent('mouseup', function() {
		var currentPosition = parseInt($('aoi__galleryScroller').getStyle('left'));
		if(steps > 0) {
			$('aoi__galleryScroller').tween('left', currentPosition+672);
			steps--;
			if(steps == 0) {
				$('aoi__galleryLeft').set('opacity', 0.25);
				$('aoi__galleryLeft').setStyle('cursor','default');
			}
			
			$('aoi__galleryRight').set('opacity', 1);
			$('aoi__galleryLeft').setStyle('cursor','pointer');
		}
	});
	if(maxSteps == 0){
		$('aoi__galleryRight').set('opacity',0.25);
		$('aoi__galleryLeft').setStyle('cursor','default');
	}
	
	$('aoi__galleryRight').addEvent('mouseup', function() {
		var currentPosition = parseInt($('aoi__galleryScroller').getStyle('left'));
		if(steps < maxSteps) {
			$('aoi__galleryScroller').tween('left', currentPosition-672);
			steps++;
			if(steps == maxSteps) {
				$('aoi__galleryRight').set('opacity',0.25);
				$('aoi__galleryLeft').setStyle('cursor','default');
			}
			$('aoi__galleryLeft').set('opacity', 1);
			$('aoi__galleryLeft').setStyle('cursor','pointer');
			
		}
	});
	
	$$('.aoi__pagination').each(function(pagination) {
		pagination.addEvent('mouseup', function() {
			var scrollStep = parseInt(pagination.id);
			$('aoi__galleryScroller').tween('left','-'+scrollStep*672+'px')
			steps = scrollStep;
			if(scrollStep == maxSteps) {
				//steps++;
				$('aoi__galleryRight').set('opacity',0.25);
				$('aoi__galleryRight').setStyle('cursor','default');
				$('aoi__galleryLeft').set('opacity',1);
				$('aoi__galleryLeft').setStyle('cursor','pointer');
			} else if(steps == 0) {
				$('aoi__galleryLeft').set('opacity',0.25);
				$('aoi__galleryLeft').setStyle('cursor','default');
				$('aoi__galleryRight').set('opacity',1);
				$('aoi__galleryRight').setStyle('cursor','pointer');
			} else {
				$('aoi__galleryLeft').set('opacity',1);
				$('aoi__galleryLeft').setStyle('cursor','pointer');
				$('aoi__galleryRight').set('opacity',1);
				$('aoi__galleryRight').setStyle('cursor','pointer');
			}
		});
	});
}



//  ################################################################################################################
// 	initPortraitInfos()
//	
//	
//  ################################################################################################################

JS__showPortraits_previousSlide = null;
				
function initPortraitInfos() {
	var slideArray = new Array();
	$$('.JS__showPortraits').each(function(e){
		var mySlide = new Fx.Slide(e.id+"DIV");
		slideArray.push(mySlide);
		mySlide.hide();
		
		$(e.id+"DIV").setStyle("display","block");
		e.addEvent('click', function(e){
			if(JS__showPortraits_previousSlide!=null){
				JS__showPortraits_previousSlide.slideOut();
			}
			this.slideIn();
			JS__showPortraits_previousSlide = this;
		}.bind(mySlide));
	});
	
}



//  ################################################################################################################
// 	
//	CALL ALL FUNCTIONS
//	
//  ################################################################################################################


$(window).addEvent("load", function() {
	getScreenWidth()
	if($('backgroundContainer') != null) { 
		setBackgroundImage(); 
		if($('leftContainer') != null) { 
			swapImages('start');
			slideNavigation(); 
			$('leftContainer').setStyle('display', 'block');
			$('rightContainer').setStyle('display', 'block');
		}
		scaleMoodDivs();
		if($('aoi__startLogo') != null) { setLogoPosition(); }
	}
	
	if($('backgroundContainer') != null || $('sliderScrollContainer') != null) { 
		if($('leftContainer') != null) {  setTimeout(function() { fadeScrollButtons() }, 4000); }
	}
	
	if($('aoi__articleGallery') != null) { 
		setBackgroundImage1(); 
		swapImages('gallery');
		slideNavigationGallery();
	}
	
	if($('gruppentickets') != null) { getTicekts(); }
//	showSubNavigation();
	mainNavigationStauts();
	if (!Browser.ie){ audioPlay(); }
});

$(window).addEvent("domready", function() {
	if($('backgroundContainer') != null) { setFirstBackgroundImage(); }
	if($('aoi__galleryScroller') != null) { galleryScroller(); }
	if($('aoi__calendarContainer') != null) { eventScroller(); }
	if($('aoi__newsOverview') != null) { newsScroller(); }
	if($('aoi__hofSliderContainer') != null) { hofScroller(); }
	if($('aoi__newsCategorySliderContainer') != null) { newsCategoryScroller(); }

	if((isIPhone() || isIPad()) && $('subNaviDIV') != null) {	
		/* Die zu bewegende Navigation wird ermittelt. */
		var navi 	= $('subNaviUL');   
		/* Die Navigationspunkte werden gezählt damit die Scrolldistanz ausgerechnet werden kann */
		var items 	= navi.getElements('li[class*=item]');      
		/* Die Navigationselemente werden gezählt und der Navicontainer entsprechned skaliert */
		navi.setStyle('width', (items.length*253)+42);
		setTimeout(function () {
			myiScroll = new iScroll('subNaviDIV',{ vScroll: false, hScrollbar: false, vScrollbar: false });
		}, 100);
	} else if($('subNaviDIV') != null) { scrollMenu(); }
	
	if($$('.JS__showPortraits').length != 0) { initPortraitInfos() }
});

$(window).addEvent("resize", function() {
	if($('backgroundContainer') != null) {
		setBackgroundImage();
		getScreenWidth();
		if($('leftContainer') != null) { slideNavigation(); }
		scaleMoodDivs();
		if($('aoi__startLogo') != null) { setLogoPosition(); }
	}
});










//  ################################################################################################################
// 	
//	Detect iOS Device -- iPhone | iPad
//	
//  ################################################################################################################

var userAgent=navigator.userAgent.toLowerCase();var platform=navigator.platform.toLowerCase();
function isIDevice(){if(isIPhone()||isIPad()){return true}else{return false}}
function isIPhone(){if(platform.search("iphone")>-1||platform.search("ipod")>-1){return true}else{return false}}
function isIPad(){if(platform.search("ipad")>-1){return true}else{return false}}

