$(function() {
	/* hide all errors */
	$('.error').hide();
	/* on submit button click */
	$('input[name=submit-form]').click(function() {
		/* input text names of required fields */
		var text = new Array('nome', 'email');
		/* radio buttons names required */
		for(i=0;i<text.length;i++) { var textfield = $("input[name=" + text[i] + "]").val(); if(!textfield) { $("." + text[i] + "_error").show(); $("input[name=" + text[i] + "]").focus(); return false; } else { $("." + text[i] + "_error").hide(); } }
		$.ajax({
			type: "POST",
			/* php file email sender */
			url: "newsletter/sendmail.php",
			/* form class or id */
			data: $("#formulario-newsletter").serialize() + "&submit-form=" + $('input[name=submit-form]').val(),
			success: function() {
				/* puts a div with class message inside class form - you may change it */
				$('#formulario-newsletter').html("<div class='msg'></div>");
				/* sucess message - put the class or id of the message container */
				$('.msg').html("<h3>Subscreveu-se com sucesso!</h3>")
				/* another message */
				.append("<br/><p>Em breve receberá noticias nossas no seu email</p>");
			}
		});
		return false;
	});
});
