$(document).ready(function(){ 
						   
  // Browserdetection
	var opera = false;
	jQuery.each(jQuery.browser, function(i, val) {
		if (i == 'opera' && val == true) {
			opera = true;
		}
	});
  
  // Animated Scrolling
  if (!opera) {
	  $('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
		  var $target = $(this.hash);
		  $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
		  if ($target.length) {
			var targetOffset = $target.offset().top;
			$('html,body').animate({scrollTop: targetOffset}, 1000);
		   return false;
		  }
		}
	  });
  }
  
  // Toggle Elements
  $("li h2").click(function(){
	$(this).next(".toggleContent").slideToggle(400);
  });
  
  // Links mit mousecursor
  $('a').css("cursor","pointer");
  
  // Formular Rückruf
	$('#rueckruf_submit').click(function() {
		var fehler = false;
		if ($('#rueckruf_name').val() == '' || $('#rueckruf_telefon').val() == '') {
			fehler = true;	
		}
		if (!fehler) {
			$.post('/php/_forms_.php',
				   $('#form_rueckruf').serialize(),
				   function(data) { 
						$('#form_rueckruf').html(data); 
				   }
			);
			$('#form_rueckruf').html('<p>bitte warten</p>');
		} else {
			alert("Bitte Name und Telefonnummer angeben. Danke!");	
		}
	});
	
	// Formular Kontakt
	$('#kontakt_submit').click(function() {
		var fehler = false;
		if ($('#form_nachricht').val() == '' || $('#form_name').val() == '' || $('#form_email').val() == '') {
			fehler = true;	
		}
		if (!fehler) {
			$.post('/php/_forms_.php',
				   $('#form_kontakt').serialize(),
				   function(data) { 
						$('#form_kontakt').html(data); 
				   }
			);
			$('#form_kontakt').html('<p>bitte warten</p>');
		} else {
			alert("Bitte Nachricht, Name und E-mail angeben. Danke!");	
		}
	});
  
});