
// Zeit für Einblenden in Sekunden:
var bildwechsel_einblenden = 2;

// Pause zwischen Bildwechsel in Sekunden:
var bildwechsel_pause = 5;


function bildwechsel(nr) {
	if (nr >= $('#bildwechsel > div').size()) {
		// Rekursion abbrechen, Ursprungsbild anzeigen:
		$('#bildwechsel > div').fadeTo(1000, 0.0, function(){
			$(this).css('z-index', 0);
		});
	} else {
		// Rekursiver Aufruf des nächsten Bildes:
		$('#bildwechsel > div').eq(nr).css('z-index', 200 + nr);
		$('#bildwechsel > div').eq(nr).fadeTo(bildwechsel_einblenden * 1000, 1.0, function(){
			$(this).fadeTo(bildwechsel_pause * 1000, 1.0, function(){
				bildwechsel(nr + 1);
			});
		});
	}
}

$(function() {
	
	$('#bild > img').fadeTo(0, 0.0);
	$('#bildwechsel > div').fadeTo(0, 0.0);
	$('#bild > img').fadeTo(bildwechsel_einblenden * 1000, 1.0, function () {
		$(this).fadeTo(bildwechsel_pause * 1000, 1.0, function(){
			bildwechsel(0);
		});
	});
	
	
	$('.detail-link.open').click(function() {
		$(this).fadeOut(500, function() {
			//$('.detail-block').slideDown(700, function() {
			$('.detail-block').show(1, function() {
				$("html:not(:animated),body:not(:animated)").animate({scrollTop: $(this).offset().top}, 1000, "swing");
				$('.detail-link.close').fadeIn(500);
			});
		});
	});
	$('.detail-link.close').click(function() {
		$(this).fadeOut(500, function() {
			$('.detail-block').slideUp(700, function() {
				$('.detail-link.open').fadeIn(500);
			});
		});
	});

	
	$('a.popup').fancybox({
		'autoDimensions' : false,
		'width' : 625,
		'height': 400,
		'margin': 5,
		'padding': 5,
		'overlayOpacity':0.4,
		'titleShow': false,
		'enableEscapeButton': true,
		'showCloseButton': true,
		'hideOnContentClick': false
	});
	
	$('a.popup-gross').fancybox({
		'autoDimensions' : false,
		'width' : 625,
		'height': 500,
		'margin': 5,
		'padding': 5,
		'overlayOpacity':0.4,
		'titleShow': false,
		'enableEscapeButton': true,
		'showCloseButton': true,
		'hideOnContentClick': false
	});
	
	$('a.popup-iframe').fancybox({
		'type' : 'iframe',
		'autoDimensions' : false,
		'width' : 645,
		'height': 460,
		'margin': 5,
		'padding': 5,
		'scrolling': 'no',
		'overlayOpacity':0.4,
		'titleShow': false,
		'enableEscapeButton': true,
		'showCloseButton': true,
		'hideOnContentClick': false
	});

});
