// JavaScript Document

function checkForm() {
	var myForm = document.forms.contactForm;
	
	if (!myForm.name.value && !myForm.company.value) {
		alert('Por favor, ingrese su nombre o el nombre de su empresa.');
		myForm.name.focus();
		return false;
	}
	
	if (!myForm.email.value) {
		alert('Por favor, ingrese su dirección de mail.');
		myForm.email.focus();
		return false;	  
	}
	else {
		if (!validEmail(myForm.email.value)) {
			alert('La dirección ingresada no es válida. Inténtelo de nuevo.')
			myForm.email.focus();
			return false;
		}
	}
	
	if (!myForm.subject.value) {
		alert('Por favor, ingrese el asunto del mensaje.');
		myForm.subject.focus();
		return false;
	}
	
	if (!myForm.comments.value) {
		alert('Por favor, ingrese el mensaje.');
		myForm.comments.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;
}