function trim(str){
	if(!str || typeof str != 'string'){
		return "";
	}
	return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}
function validate(){
	var email = trim(window.document.mform.email.value);
	if(trim(window.document.mform.name.value) == ''){
		alert('Escriba su nombre');
		window.document.mform.name.focus();
		return false;
	}
	else if (trim(window.document.mform.persona.value) == ''){
	    alert('Escriba la persona de contacto');
		window.document.mform.persona.focus();
		return false;
	}
	else if(trim(window.document.mform.telefono.value) == ''){
	    alert('Escriba su teléfono de contacto');
		window.document.mform.telefono.focus();
		return false;
	}
	else if(email == ''){
		alert('Escriba su dirección de e-mail');
		window.document.mform.email.focus();
		return false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))){
		alert("Dirección de e-mail no válida");
		window.document.mform.email.focus();
		return false;
	}
	else if(trim(window.document.mform.comments.value) == ''){
		alert('Escriba su consulta');
		window.document.mform.comments.focus();
		return false;
	}
	else{
		window.document.mform.name.value = trim(window.document.mform.name.value);
		window.document.mform.telefono.value = trim(window.document.mform.telefono.value);
		window.document.mform.email.value = email;
		window.document.mform.comments.value = trim(window.document.mform.comments.value);
		return true;

	}
}