$(document).ready(function() {
	if($('.fadeItem').length) {
		$('#fade1').show().addClass('active');
		
		$('#subnav a').click(function() {
			$('#subnav a').removeClass('active');
			$(this).addClass('active');
			var item = $(this).attr('rel');
			
			$('#main .active').fadeOut('slow').removeClass('active');
			$('#fade'+item).fadeIn('slow').addClass('active');
			
			console.log('click');
			return false;
		});
	}
	
	if($('#footer')) {
		//$('#aerzte li').first().addClass('active first');
		//$('#aerzte li').last().addClass('last');
		//aerztefader();
    $('#aerzte div ul').cycle({
		fx: 'fade',
		timeout: 10000,
		width: 400
	});
	}
	
	if($('#galerie')) {
		rundgang();
	}
});

function aerztefader() {
	$('#aerzte li.active').fadeIn('slow').delay('10000').fadeOut('slow', function() {
		if($(this).hasClass('last')) {
			$('#aerzte li').first().addClass('active');
			$(this).removeClass('active');
		} else {
			$(this).next().addClass('active');
			$(this).removeClass('active');
		}
		aerztefader();
	});
}

function rundgang() {
	$('#galerie img').click(function() {
		var path = document.domain;
		var bild = $(this).attr('rel');
		
		$('#grossansicht').fadeOut(function() {
			$(this).attr('src','http://'+path+'/img/rundgang/'+bild+'.jpg').fadeIn()
		});
	});
}
