// JavaScript Document
function checkNewsForm() {
	var myForm = document.forms.newsForm;
	
	if (!myForm.name.value) {
		alert('Por favor, ingrese su nombre.');
		myForm.name.focus();
		return false;
	}

	if (!myForm.email.value) {
		alert( 'Por favor, ingrese su email.' );
		myForm.email.focus();
		return false;
	}
	else {
		if (!validEmail( myForm.email.value )) {
			alert( 'El Email ingresado no es válido. Por favor, inténtelo de nuevo.' );
			myForm.email.focus();
			return false;
		}
	}

	if (!myForm.terms.checked) {
		alert( 'Debe aceptar los términos y condiciones.' );
		myForm.terms.focus();
		return false;
	}

	return true;
}

function validEmail( email ) {
	mailReg = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;
	if (email.match(mailReg) )
		return true;
	else
		return false;
}
