var options = { 

	beforeSubmit:  validate,  // pre-submit callback 

	success:       showResponse,  // post-submit callback 

	resetForm: true        // reset the form after successful submit 

}; 

				
$('#newsletterform').ajaxForm(options); 

				
function showResponse(responseText, statusText){

	$('#successen').animate({ opacity: "show" }, "fast")

}

				

function validate(formData, jqForm, options) {

	$("p.errors").animate({ opacity: "hide" }, "slow");

			 

	var nameValue = $('input[name=theName]').fieldValue(); 

	var emailValue = $('input[name=theEmail]').fieldValue();

	

	

	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

	var correct = true;

	

	if (!nameValue[0]) {

		$("p.errors.wrong_name").animate({ opacity: "show" }, "slow");

		correct = false;

	}

	

	if (!emailValue[0]) {

		$("p.errors.wrong_email").animate({ opacity: "show" }, "slow");

		correct = false;

	} else if(!emailReg.test(emailValue[0])) {

		$("p.errors.wrong_email").animate({ opacity: "show" }, "slow");

		correct = false;

	}

	

		

	if (!correct) {return false;}

} 	


				

$("p#successen").click( function () { 

	$(this).animate({ opacity: "hide" }, "slow"); 

});								 