
// verifica email
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+','
win = window.open(mypage,myname,settings)
}

var win = null;
function verifica() {
  a = document.check;
  err = true;
  msg = "";
  if (a.resposta.value.length == 0){
	  check.resposta.focus();
      err = false;
	  msg += "\n- Adicione uma resposta.";
  }
  
if (!isEmail(a.autor_email.value)) {
              check.autor_email.focus();
      err = false;
	  msg += "\n- Adicione um e-mail válido.";
          }
  
  if (a.autor.value.length == 0){
	  check.autor.focus();
      err = false;
	  msg += "\n- Adicione seu nome.";
  }
 

  if(err == false){
  	  alert("Reveja os seguintes campos: \n" + msg);
  } else {
	  enviando();
  }
}
//mensagem enviando...
function enviando() {
	document.getElementById("status").innerHTML = 'Enviando aguarde...'; 
}

//faz a verificação do email
function isEmail(s)
{
    // email text field.
    var sLength = s.length;
    var denied_chars = new Array(" ", "\n", "\t", "\r", "%", "$", "#", "!", "~", "`", "^", "&", "*", "(", ")", "=", "+", "{", "}", "[", "]", ",", ";", ":", "'", "\"", "?", "<", ">", "/", "\\", "|");

    // look for @
    if (s.indexOf("@") == -1) return false;

    // look for more than one @ sign
    if (s.indexOf("@") != s.lastIndexOf("@")) return false;

    // look for any special character
    for (var z = 0; z < denied_chars.length; z++) {
        if (s.indexOf(denied_chars[z]) != -1) return false;
    }

    // look for .
    if (s.indexOf(".") == -1) return false;

    // no two dots alongside each other
    if (s.indexOf("..") != -1) return false;

    // the last character cannot be a .
    if ((s.charAt(sLength-1) == ".") || (s.charAt(sLength-1) == "_")) return false;

    return true;
}