function trim(s) {
  while (s.substring(0, 1) == ' ') {
    s = s.substring(1, s.length);
  }
  while (s.substring(s.length - 1, s.length) == ' ') {
    s = s.substring(0, s.length - 1);
  }
  return s;
}


function validarEmail(email)
{
  if ((email.length != 0) && ((email.indexOf("@") < 1) || (email.indexOf('.com') < 5)))
  {
  	return false;
  }
  return true;
}


function checkContato() {
	var nome = document.getElementById('nome');
	var email = document.getElementById('email');
	
	if (trim(nome.value) == "") {
		alert('Campo Nome vazio!');
		nome.focus();
		return false;
	}
	if (trim(email.value) == "") {
		alert('Campo Email vazio!');
		email.focus();
		return false;
	}
	if (! validarEmail(email.value)) {
		alert('Campo Email incorreto!');
		email.focus();
		return false;
	}
	return true;
}