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.nome.value) == ''){
		alert('Escriba su nombre / Write your name');
		window.document.mform.nome.focus();
		return false;
	}
	else if(email == ''){
		alert('Escriba su dirección de email / Write your email address');
		window.document.mform.email.focus();
		return false;
	}
	else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))){
		alert("Dirección no válida / Invalid address");
		window.document.mform.email.focus();
		return false;
	}
	else if(trim(window.document.mform.consulta.value) == ''){
		alert('Escriba su consulta / Write your comments');
		window.document.mform.consulta.focus();
		return false;
	}
	else{
		window.document.mform.nome.value = trim(window.document.mform.nome.value);
		window.document.mform.email.value = email;
		window.document.mform.consulta.value = trim(window.document.mform.consulta.value);
		return true;

	}
}
