//Termin Slider
$(function(){
	$('#viewTermine').click(function(){		
		$('#terminefeld').slideToggle('slow');		
	});	
});
//Alle Kommentare ansehen
$(function(){
	$('#gbpopup').click(function(){
		window.open("kommentare.php" , "kommentare", 
"status = 1, height = 600, width = 600, resizable = 0, scrollbars=yes" )
	});
});
//Impressum Popup
$(function(){
	$('#impressumpopup').click(function(){
		window.open("impressum.php" , "impressum", 
"status = 1, height = 600, width = 600, resizable = 0, scrollbars=yes" )
	});
});
//Kontakt Popup
$(function(){
	$('#kontaktpopup').click(function(){
		window.open("kontakt.php" , "kontakt", 
"status = 1, height = 350, width = 500, resizable = 0" )
	});
});
//Ajax Kommentare
$(function(){
	$('#ksenden').click(function(){
		
		$('#ladeinfo').append('<div id="loading"><img src="images/loading.gif" alt="lade..." id="ladegif"/></div>');
		
		var name = $('#kommentarname').val();
		var inhalt = $('#kommentartext').val();
		
		$.ajax({		
			url: 'eintragen.php',
			type: 'POST',
			data: {'name' : name , 'inhalt' : inhalt },			
			success: function(result){
				$('#resultinfo').remove();
				$('#ladeinfo').append('<p id="resultinfo">' + result + '</p>');
				$('#ladegif').fadeOut(500, function(){
					$(this).remove();
				});
			}
		
		});	
		return false;
	});
	
});
//Ajax Foto Lightbox
$(function(){
	$('#inhalt a.fotosetlink').click(function(){	
	
		var fotoset = $(this).attr('title');
		$('body').append('<div id="loading2"><img src="images/loading2.gif" alt="lade..." id="ladegif" border="0"/></div>');
		$('body').append('<div id="lightbox"></div>');		
		$('#lightbox').fadeIn(1000);		
		$('body').append('<div id="close"><a href="#" id="closelink">schliessen</a></div>');
		$('#close').hide().fadeIn(1000);
		
		//Schliessen Link Lightbox ausfaden und removen
		$('#close a').click(function(){
			$('#close').fadeOut(1000, function(){
				$(this).remove();
			});
			$('#lightbox').fadeOut(1000, function(){
				$(this).remove();
				$('body').css('overflow', 'auto');
			});
			
			return false;
		});
				
		$.ajax({
			url: 'fotoset.php',
			type: 'GET',
			data: {'set' : fotoset},
			success: function(result){
				$('#lightbox').append('<div id="results">' + result + '</div>');
				$('#results').hide().fadeIn(1000);
				$('body').css('overflow', 'hidden');
				$('#loading2').fadeOut(500, function(){
					$(this).remove();
				});
			}
		});
		return false;
	});
});


$(function(){ 
    	//Browser breite/höhe und Wrapper breite/höhe abfragen
    	var breite = document.documentElement.clientWidth; 
    	var hoehe = document.documentElement.clientHeight;
    	var wrapper_breite = $('#foto_wrapper').width();
    	var wrapper_hoehe = $('#foto_wrapper').height();
    	
    	//Wrapper im Browser centern
    	$('#foto_wrapper').css({'position':'absolute',
    										 'top': ( hoehe / 2 )-( wrapper_hoehe / 2 ),
    										 'left': ( breite / 2 )-( wrapper_breite / 2 )
    									  });
    									  
    	//erscheinen den pfeil divs beim hover
    	/*$('#image_wrapper').hover(function(){
    		$('#next').fadeIn(500);
    	}, function(){
    		$('#next').fadeOut(500);
    	});*/
    	
    	//Wieviele Bilder 
    	var anzahl = $('#foto_wrapper img').size();
    	   	
    	//next Image Funktion
    	$('#foto_wrapper img').hide();
    	var zahl = 1;
    	$('img#' + zahl).show();
    	$(this).click(function(){
    		zahl++;
    		$('img#' + zahl).show();
    		if(zahl > anzahl){
    			$('#foto_wrapper img').hide();
					$('img#1').show();
    			zahl = 1;
    			$('#img' + zahl).show();
    		}
    	}); 
});

