window.addEvent('domready', function() {

		var myBubbles = $$('.bubble-item');

		if(Browser.Engine.trident == true){
			myBubbles.setStyle('visibility', 'hidden');
		}else{
			myBubbles.setStyle('opacity', 0);
		}
		$('h_bubble').setStyle('visibility','visible');


		$('h_head_nav').getElements('li').each(function(el, i) {

			el.set('morph', {link : 'cancel'});

			el.addEvents({
				'mouseenter': function() {

					if(Browser.Engine.trident != true){
						myBubbles.morph({
							'opacity' : 0
						});

						myBubbles[i].morph({
							'opacity' : 1,
							'margin-bottom' : '-15px'
						});
					}else{
						myBubbles.morph({
							'visibility' : 'hidden'
						});

						myBubbles[i].morph({
							'visibility' : 'visible',
							'margin-bottom' : '-15px'
						});
					}

				},
				'mouseleave' : function() {

					(function(e){

						if(Browser.Engine.trident != true){
							myBubbles[i].morph({
								'opacity' : 		0,
								'margin-bottom' : 	0
							});
						}else{
							myBubbles[i].morph({
								'visibility' : 		'hidden',
								'margin-bottom' : 	0
							});
						}
					}).delay(5000);

				}
			});
		});

		myBubbles.each(function(el){

			el.set('morph', {link : 'cancel'});

			el.addEvents({
				'mouseleave': function() {

					if(Browser.Engine.trident != true){
						el.morph({
							'opacity' : 0,
							'margin-bottom' : 0
						});
					}else{
						el.morph({
							'visibility' : 'hidden',
							'margin-bottom' : 0
						});						
					}
				}

			});
		});

	// Fuer slide Link
		$$('.noClick').addEvent('click', function(e){
			e.stop();
		});

	// Code fuer die Subnavigation
		var totIncrement		= 0;
				if(Browser.Engine.trident == true){
					var increment			= 22;
				}else{
					var increment			= 20;
				}

		var fx = new Fx.Tween('h_content_footer_sub', {
					duration: 500,
					transition: Fx.Transitions.Back.easeInOut,
					wait: true
		 });

	 /* Von der Liste mit der ID h_c_main, fuer jedes li element von der Liste...: */
		$('h_c_main').getElements('li').each(function(e){

			/* ...besorgt die ID des ausgewaehlten Objekt */
			e.getElement('a').addEvent('mouseover', function(listID){
				totIncrement = - increment * listID;
				fx.cancel();
				fx.start('margin-top',totIncrement);
			}.pass(e.id));

		});

	/* Kontrolle ob ein Hauptpunkt ausgewaehlt ist */
	/* wenn Propert 'rel' existiert = beweg */
	$('h_c_main').getElements('a').each(function(e,index){
		if(e.hasClass('current')){
				totIncrement = - increment * e.getProperty('rel');
				fx.cancel();
				fx.start('margin-top',totIncrement);
		}
	});


	if($('main-adv-hrz-stage') != null){
		var num = 0;
			$('main-adv-hrz-stage').getElements('div').each(function(e,index){
				num = num + index;
			});

			if(num == 1){ num++; }

		if(num > 1){
			var i = 1;
//			(function(){ FadeAdv(null,'main-adv-hrz-pic','main-adv-2'); }).delay(1000);
			(function(){

				if( i > num){ i = 1; }

					FadeAdv(null,'main-adv-hrz-pic','main-adv-'+i);
					i++;

			 }).periodical(2500);
		}
	}


	if($('main-adv-vrt-stage') != null){
		var num = 0;
			$('main-adv-vrt-stage').getElements('div').each(function(e,index){
				num = num + index;
			});

			if(num == 1){ num++; }

		if(num > 1){
			var i = 1;
//			(function(){ FadeAdv(null,'main-adv-vrt-pic','main-adv-2'); }).delay(1000);
			(function(){

				if( i > num){ i = 1; }

					FadeAdv(null,'main-adv-vrt-pic','main-adv-'+i);
					i++;

			 }).periodical(2500);
		}
	}

});

function FadeAdv(key,id,neu,max){

	if($$('.'+id).length > 0){
		$$('.'+id).each(function(el){
			if(el.hasClass('current') == true){
				if(el.getProperty('id') != neu){
					$$('.'+id+'#'+neu).setStyle('z-index',2);

					el.fade('out').get('tween').chain(function() {
						el.removeClass('current');
						el.setStyle('z-index',0);
						$$('.'+id+'#'+neu).setStyle('z-index',3);
						$$('.'+id+'#'+neu).addClass('current');
						el.fade('in');
					});
				}
			}
		});
	}

	if(key != null){
		$$('#'+key+' li a').removeClass('current');
		var sliders = neu.split('-');
	 	$('a'+sliders[2]).addClass('current');
	}
}

function ShowInfo(id,pram_duration){
	if($(id) != null){
		if(pram_duration == null){ pram_duration = 1500; }

		var mySlideSearch = new Fx.Slide($(id),{ duration: pram_duration });
		mySlideSearch.toggle();
	}
}

function Slides(id,box){
	if($(id) != null){

		var pram_duration = 500;

		var mySlideSearch = new Fx.Slide($(id),{ duration: pram_duration });
		mySlideSearch.toggle();

	}
}

function hideAll(box,modus){
	if(box != ''){
		if(modus == null){ modus = 'hide'; }
		// Hide jedes mit der Klasse .item_list
			box.each(function(el){
				var myFx = new Fx.Slide(el);
				if(modus == 'hide'){
					myFx.hide();
				}else if(modus == 'slide'){
					myFx.slideOut();
				}
			});
	}
}
