
$(document).ready(function(){
						   
	//submission scripts
  $('.signupForm').submit( function(){
					
		var error = false;
		
		//	check name
		var name = document.getElementById('name');
		if (name.value == "Your Name:") {
			$('.name-missing').show();
			error = true;
		} else {
			$('.name-missing').hide();
		}	
						 
		//	check email	
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var email = document.getElementById('e-mail');
		if (!filter.test(email.value)) {
			$('.email-missing').show();
			error = true;
		} else {
			$('.email-missing').hide();
		}
		
		//	check name
		var message = document.getElementById('message');
		if (message.value == "Your Message:") {
			$('.message-missing').show();
			error = true;
		} else {
			$('.message-missing').hide();
		}	
			
		if (!error) {
			//hide the form
			$('.signupForm').hide();
		
			//show the loading bar
			$('.loader').append($('.bar'));
			$('.bar').css({display:'block'});
		
			//send the ajax request
			$.post('form.php',{name:$('#name').val(),
							  email:$('#e-mail').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;
		
  });

});
