









	var main_navigation = Class.create({
	
		initialize: function() {
		
			this.active_visual = false;
			this.startitem = 'entdecken';
			this.switchbacktimer = false;
			
			this.currentitemindex = 0;
			
			if(__page == 'entdecken' || __page == 'bereisen' || __page == 'erleben') this.startitem = __page;
			if(__page == 'informationen' || __page == 'suche') this.startitem = false;
			
			this.buttons = ['entdecken', 'erleben', 'bereisen'];
			
			this.buttons.each(function(a) {
			
				if(a != this.startitem) {
					$('visual-'+a).setStyle('display: none; top: 450px');
				}
				else {
					this.active_visual = $('visual-'+a);
					this.setActiveButton(a);
				}
			
				$('b-'+a).up().onmouseover = function() {
				
					this.mouseOverButton(a);
				
				}.bind(this);				
				
				$('b-'+a).up().onmouseout = function() {

					this.switchbacktimer = window.setTimeout(function() {
						this.switchback();
					}.bind(this), 200);
				
				}.bind(this);
				
			}.bind(this));
			
			$$('ul.subnav').each(function(a,b) {
			
				new Insertion.Top(a, '<li class="b-navscroll-left"><a href="#">zurück</a></li>');
				new Insertion.Bottom(a, '<li class="b-navscroll-right"><a href="#">vor</a></li>');
				
				a.select('.b-navscroll-left')[0].observe('click', function(e) {
					this.scroll(-1, e);
					Event.stop(e);
				}.bind(this));
				
				a.select('.b-navscroll-right')[0].observe('click', function(e) {
					this.scroll(1, e);
					Event.stop(e);
				}.bind(this));
				
				this.setItemVisibility(a, 1);
			
			}.bind(this));
		
		},
		
		mouseOverButton: function(which) {
		
			this.clearSwitchBackTimer();
			this.resetActiveButtons();

			if(this.active_visual && this.active_visual != $('visual-'+which)) {
				new Effect.Morph(this.active_visual, { 
					style: { top: '450px' },
					duration: 0.1,
					afterFinish: function() {
						this.active_visual.hide();
						this.showVisual(which);
					}.bind(this)
				});
			}

			else {
				this.showVisual(which);
			}

			this.setActiveButton(which);
		
		},
		
		clearSwitchBackTimer: function() {
		
			if(this.switchbacktimer) { 
				window.clearTimeout(this.switchbacktimer); 
			}
		
		},
		
		switchback: function() {
		
			if(this.buttons.indexOf(__page) != -1) {
				this.mouseOverButton(__page);
			}
		
		},
		
		showVisual: function(which) {
		
			this.active_visual = $('visual-'+which);
		
			$('visual-'+which).show();
		
			new Effect.Morph($('visual-'+which), {
				style: { top: '0px' },
				duration: 0.1
			});
		
		},
		
		resetActiveButtons: function() {
		
			this.buttons.each(function(a) {
			
				$('b-'+a).removeClassName('active');
			
			});
		
		},
		
		setActiveButton: function(which) {
		
			$('b-'+which).className = 'active';
		
		},
		
		scroll: function(dir, e) {
		
			elmt = Event.findElement(e);
			elmt_ul = elmt.up().up();
			
			newindex = ((elmt_ul.currentitemindex+dir) > 3) ? 1 : (elmt_ul.currentitemindex+dir);
			newindex = (newindex < 1) ? 3 : newindex;
			
			if(elmt_ul.hasClassName('subnav-bereisen')) { 
				newindex = ((elmt_ul.currentitemindex+dir) > 2) ? 1 : (elmt_ul.currentitemindex+dir);
				newindex = (newindex < 1) ? 2 : newindex;
			}
			
			this.setItemVisibility(elmt_ul, newindex);
		
		},
		
		setItemVisibility: function(elmt, index) {
		
			elmt.currentitemindex = index;
		
			start = (index-1)*12;
			end = (index-1)*12+12-1;
		
			elmt.select('li:not([class])').invoke('hide');
		
			elmt.select('li:not([class])').each(function(a,b) {
			
				if(b>=start && b<=end) {
					a.appear({ duration: 0.2 });
				}
			
			});
		
		}
	
	});








	var visuals = Class.create({
	
		initialize: function() {	
		
			$('with-javascript').setOpacity(1);
		
			jQuery('#visual-bereisen').jparallax({}, 
				// vögel
				{
					ytravel: '0px',
					xtravel: '20px',
					myxoffset: 0,
					myyoffset: -45
				}, 
				// hotels
				{
					ytravel: '0px',
					xtravel: '40px',
					myxoffset: 35,
					myyoffset: -10
				}, 
				// flughäfen
				{
					ytravel: '0px',
					xtravel: '60px',
					myxoffset: 170,
					myyoffset: 20
				},
				// regionalverkehr
				{
					ytravel: '0px',
					xtravel: '60px',
					myxoffset: -110,
					myyoffset: 60
				},
				// fähren
				{
					ytravel: '0px',
					xtravel: '60px',
					myxoffset: 110,
					myyoffset: 110
				},
				// nahverkehr
				{
					ytravel: '0px',
					xtravel: '100px',
					myyoffset: 80,
					myxoffset: 50
				},
				// u-bahnen
				{
					ytravel: '0px',
					xtravel: '100px',
					myyoffset: 110,
					myxoffset: -90
				},
				// laterne
				{
					ytravel: '0px',
					xtravel: '115px',
					myyoffset: 105,
					myxoffset: -25
				},
				// taxis
				{
					ytravel: '0px',
					xtravel: '130px',
					myyoffset: 145,
					myxoffset: -25
				}
			);
			
			
			jQuery('#visual-entdecken').jparallax({}, 
				// vögel
				{
					ytravel: '0px',
					xtravel: '10px',
					myxoffset: -40,
					myyoffset: -65
				}, 
				// park inn
				{
					ytravel: '0px',
					xtravel: '30px',
					myxoffset: 35,
					myyoffset: -10
				}, 
				// potsdamer platz
				{
					ytravel: '0px',
					xtravel: '40px',
					myxoffset: -140,
					myyoffset: 0
				},
				// rathaus
				{
					ytravel: '0px',
					xtravel: '50px',
					myxoffset: -100,
					myyoffset: 55
				},
				// fernsehturm
				{
					ytravel: '0px',
					xtravel: '60px',
					myxoffset: -10,
					myyoffset: -140
				},
				// berliner dom
				{
					ytravel: '0px',
					xtravel: '70px',
					myxoffset: 100,
					myyoffset: 40
				},
				// sony-center
				{
					ytravel: '0px',
					xtravel: '90px',
					myyoffset: 107,
					myxoffset: -125
				},
				// mauer
				{
					ytravel: '0px',
					xtravel: '100px',
					myyoffset: 150,
					myxoffset: -20
				},
				// reichstag
				{
					ytravel: '0px',
					xtravel: '120px',
					myyoffset: 119,
					myxoffset: 120
				},
				// baum
				{
					ytravel: '0px',
					xtravel: '150px',
					myyoffset: 136,
					myxoffset: -150
				},
				// bäume
				{
					ytravel: '0px',
					xtravel: '150px',
					myyoffset: 143,
					myxoffset: 173
				},
				// brandenburger tor
				{
					ytravel: '0px',
					xtravel: '160px',
					myyoffset: 123,
					myxoffset: -60
				},
				// siegessäule
				{
					ytravel: '0px',
					xtravel: '180px',
					myyoffset: 85,
					myxoffset: 28
				}
			);
			
			
			jQuery('#visual-erleben').jparallax({}, 
				// vögel
				{
					ytravel: '0px',
					xtravel: '10px',
					myxoffset: -40,
					myyoffset: -65
				}, 
				// fernsehturm
				{
					ytravel: '0px',
					xtravel: '60px',
					myxoffset: -10,
					myyoffset: -140
				},
				// ballonfahrt
				{
					ytravel: '0px',
					xtravel: '70px',
					myxoffset: 140,
					myyoffset: 20
				},
				// alexa
				{
					ytravel: '0px',
					xtravel: '90px',
					myyoffset: 40,
					myxoffset: 30
				},
				// kadewe
				{
					ytravel: '0px',
					xtravel: '100px',
					myyoffset: 35,
					myxoffset: -105
				},
				// altes museum
				{
					ytravel: '0px',
					xtravel: '120px',
					myyoffset: 112,
					myxoffset: 139
				},
				// kino
				{
					ytravel: '0px',
					xtravel: '150px',
					myyoffset: 86,
					myxoffset: -25
				},
				// baum
				{
					ytravel: '0px',
					xtravel: '150px',
					myyoffset: 130,
					myxoffset: -249
				},
				// bäume
				{
					ytravel: '0px',
					xtravel: '160px',
					myyoffset: 129,
					myxoffset: 180
				},
				// laterne
				{
					ytravel: '0px',
					xtravel: '180px',
					myyoffset: 100,
					myxoffset: 48
				},
				// friedrichstadtpalast
				{
					ytravel: '0px',
					xtravel: '170px',
					myyoffset: 112,
					myxoffset: -145
				},
				// schillertheater
				{
					ytravel: '0px',
					xtravel: '220px',
					myyoffset: 125,
					myxoffset: 45
				}
			);
		
		}
	
	});






	var tooltip_app = Class.create({
	
		initialize: function() {
		
			this.offset_y = 0;
			this.offset_x = 0;
			this.move_handler = false;
		
			if(!$('tooltip')) {
				new Insertion.Top($$('body')[0], '<div id="tooltip" style="display: none;"><p><span></span></p></div>');
			}
			
			$$('div.visuals a').each(function(a) {
			
				a.observe('mouseover', function(Event) {
					this.say(a.select('img')[0].getAttribute('alt'), Event);
				}.bind(this));
				
				a.observe('mouseout', function() {
					this.sleep();
				}.bind(this));
			
			}.bind(this));
			
			$$('a#b-suche, a#b-informationen, a#b-sprache, a#b_contentback, a#b_contentclose').each(function(a) {
			
				a.observe('mouseover', function(Event) {
					this.say(a.innerHTML, Event);
				}.bind(this));
				
				a.observe('mouseout', function() {
					this.sleep();
				}.bind(this));
			
			}.bind(this));
			
			if($('scroll-stage')) {
			
				$$('#scroll-stage a').each(function(a) {

					a.observe('mouseover', function(Event) {
						this.say(a.select('img')[0].getAttribute('alt'), Event);
					}.bind(this));

					a.observe('mouseout', function() {
						this.sleep();
					}.bind(this));

				}.bind(this));
			
			}
			
		},
		
		say: function(what, where) {
		
			$$('#tooltip span')[0].update(what);
			
			this.offset_y = -40;
			this.offset_x = -Math.floor($('tooltip').getWidth()/2);
			
			$('tooltip').setStyle('top: '+(Event.pointerY(where)+this.offset_y)+'px; left: '+(Event.pointerX(where)+this.offset_x)+'px;');
			$('tooltip').show();
			
			if(!this.move_handler) {
				Event.observe(window, 'mousemove', function(Event) { 
					this.move(Event); 
				}.bind(this));
				this.move_handler = true;
			}
		
		},
		
		move: function(where) {
		
			$('tooltip').setStyle('top: '+(Event.pointerY(where)+this.offset_y)+'px; left: '+(Event.pointerX(where)+this.offset_x)+'px;');
		
		},
		
		sleep: function() {
		
			$('tooltip').hide();
		
		}
	
	});
	
	
	
	
	
	
	
	
	var scroll_app = Class.create({
	
		initialize: function() {
		
			if($('scrolltrack')) {
			
				scroll_stage_width = 0;
				$$('#scroll-stage-content img').each(function(a) {
					scroll_stage_width += parseInt(a.getStyle('width'))+40;
				});
				$('scroll-stage-content').setStyle('width: '+scroll_stage_width+'px;');

				this.scrollslider = new Control.Slider('scrollhandle', 'scrolltrack', {				
					axis: 'horizontal',
					minimum: 0,
					maximum: 100,
					onSlide: function(u) {
						amount = (-Math.floor((u*(scroll_stage_width-749+160))));
						$('scrollhandle').setStyle('cursor: -moz-grabbing;');
						$('scrollhandle').className = 'active';
						$$('body')[0].setStyle('cursor: -moz-grabbing;');
						$('scroll-stage-content').setStyle('left: '+amount+'px;');
					},
					onChange: function(u) {
						amount = (-Math.floor((u*(scroll_stage_width-749+160))));
						$('scrollhandle').setStyle('cursor: -moz-grab;');
						$('scrollhandle').removeClassName('active');
						$$('body')[0].setStyle('cursor: auto;');
						$('scroll-stage-content').setStyle('left: '+amount+'px;');
					}
				});
				
				$('scroll-stage').observe("mousewheel", function(e) { this.wheel(e); }.bind(this), false);
				$('scroll-stage').observe("DOMMouseScroll", function(e) { this.wheel(e); }.bind(this), false);
			
			}
		
		},
		
		wheel: function(e) {
		
			newvalue = this.scrollslider.value+((Event.wheel(e)*-1)/15);
			
			if(newvalue < 0) { newvalue = 0; }
			if(newvalue > 1) { newvalue = 1; }
			
			this.scrollslider.setValue(newvalue);
		
		}
	
	});
	
	
	
	
	var search_app = Class.create({
	
		initialize: function() {
		
			if($('li-suche')) {
			
				$('b-suche').observe('click', function(e) {
					if($('li-suche').className == 'active') {
						$('li-suche').className = '';
					}
					else {
						$('li-suche').className = 'active'; 
						$('searchterm').focus();
					}
					Event.stop(e);
				});
				
				document.observe('click', function(e) {
					if(e.findElement() != $('searchterm')) {
						$('li-suche').className = '';
						window.setTimeout(function() {
							$('searchterm').value = '';
						}.bind(this), 1000);
					}
				});
			
			}
		
		}
	
	});
	
	
	
	
	
	
	var filter_app = Class.create({
	
		initialize: function() {
		
			if($('filter')) {
			
				$$('#filter a').each(function(a) {
				
					a.observe('click', function(e) { 
						this.toggle(e, a);
						Event.stop(e);
					}.bind(this));
				
				}.bind(this));
			
			}
		
		},
		
		toggle: function(e, elmt) {
		
			if(elmt) {
				if(__subpage != 'home' && $('real-page-content')) {
					$('real-page-content').hide();
					if(!$('b_resetfilter')) {
						new Insertion.Top('filters', '<li id="b_resetfilter"><a href="#">&laquo; zurück</a></li>');
						$$('#b_resetfilter a')[0].onclick = function() {
							this.reset();
							return false;
						}.bind(this);
					}
				}
			}
		
			if(elmt) elmt_name = elmt.id.replace(/filter-/, '');
		
			$$('#filter a').invoke('removeClassName', 'active');			
			if(elmt) elmt.addClassName('active');
			
			$$('#filter-lists .filter-list').invoke('hide');
			
			
			if(elmt) {
				$('filter-lists-'+elmt_name).appear({
					duration: 0.3
				});
			}
		
		},
		
		reset: function(e) {
		
			this.toggle(false, false);
		
			$('real-page-content').appear({
				duration: 0.3
			});
			
			$('b_resetfilter').remove();
		
		}
	
	});





	document.observe('dom:loaded', function() {
	
		$('no-javascript').remove();
		_c_preloader = new preloader_app();
	
	});


	window.onload = function() {
		_c_visuals = new visuals();
		_c_main_navigation = new main_navigation();
		_c_tooltip_app = new tooltip_app();
		_c_scroll_app = new scroll_app();
		_c_search_app = new search_app();
		_c_filter_app = new filter_app();
	}