function validate_email(email)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    return reg.test(email);
}

$(function(){
	$('form').submit(function(){
		if(validate_email($('#email').val()))
		{
			$.post('newsletter.php', {email: $('#email').val()});
			$(this).html('<p>Your email has been inserted in our database.');	
		}
		else
		{
			$('.text', $(this)).addClass('error');
		}
		return false;
	});
	$('form .text').focus(function(){
		if($(this).val() == "Your valid email address")$(this).val('');
	});
	$('form .text').blur(function(){
		if($(this).val() == '') $(this).val('Your valid email address');
	});
});
