function fadeTeaser() {
	//teaser fadeout
	if($('.header .toploader img').length > 0){
		$('.header .toploader img:last').delay(5000).fadeOut(1500, function() {
			//teaser fadein
			$('.header .toploader img:last').delay(5000).fadeIn(1500, function() {
				fadeTeaser();
			});
		});
	}
};

$(document).ready(function() {
	// Ajax-Type für link setzen
	if($("a.fancy-iframe").length > 0){
		$("a.fancy-iframe").attr("href", $("a.fancy-iframe").attr("href")+'?type=556');
		$('.fancy-iframe').fancybox({
			'type': 'iframe',
			'hideOnContentClick': false,
			'overlayColor': '#3d6b99',
			'overlayOpacity': 0.6,
			'height':	550
		});
		$('a.fancyclose').click(function(){
			parent.top.$('#fancybox-close').trigger('click');
		});
	}

	// Bunter Newsswitch
	if($('#newsswitch').length > 0){
		$('#newsswitch').pager('div', {
	        navId: 'newsswitch-nav',
	        navClass: 'newsswitch-navigation',
	        highlightClass: 'current'
	    });
  }

	fadeTeaser();

	$(".nav li").mouseover( function() {
		
		if ($("ol.nav li:hover div.dropdown ol").size() <= 0) {
			$("ol.nav li:hover div.dropdown").remove();
		}
	})

	if($('#newsletter-inputtext').length > 0){
		$('#newsletter-inputtext').click(
			function() {
				if (this.value == this.defaultValue) {
					this.value = '';
				}
			}
		);
		$('#newsletter-inputtext').blur(
			function() {
				if (this.value == '') {
					this.value = this.defaultValue;
				}
			}
		);
	}
	
	//Fancybox
	var basehref = $('base').attr('href');
	
	$(".videoPlayer").hover(function(){
		var video = basehref+$(this).attr('href');
		$(this).fancybox({
			'type': 'swf',
			'width': 600,
			'height': 395,
			'href': basehref+'fileadmin/template/flash/flowplayer-3.2.2.swf',
			swf: {
				flashvars: 'config={\'clip\':{\'url\': \''+video+'\'}}'
			}
	    });
	});
});

