$(document).ready(function(){
	
   //submission scripts
  $('.bbForm').submit( function(){
		//statements to validate the form	
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var email = document.getElementById('email');
				if (document.bform.name.value == "") {
			$('.name-missing').show(); $('#name').addClass('invalid');
		} else {$('.name-missing').hide(); $('#name').removeClass('invalid');}	
			if (document.bform.name.value == "") {
			return false;
		} 
		
		if (document.bform.name.value != "")  {
			//hide the form
			$('.bbForm').hide();
		
			//show the loading bar
			$('.loader').append($('.bar'));
			$('.bar').css({display:'block'});
		
			//send the ajax request
			$.post('forms/bin/bewertung.php',{name:$('#name').val(), vorname:$('#vorname').val(),
							  email:$('#email').val(),
							  phone:$('#phone').val(),
							  berater:$('#berater').val(),
							  bewertung:$('#bewertung').val(),
message:$('#message').val()},
		
			//return the data
			function(data){
			  //hide the graphic
			  $('.bar').css({display:'none'});
			  $('.loader').append(data);
			});
					
			//stay on the page
			return false;
		} 
  });
  
});