function abrirJanelaV2(h, w, imagem, nome) {

  //var altura_img = h - 29;

  Win = window.open("","","height="+h+",width="+w+",scrollbars=no,status=0,resizable=0");
  Win.document.write("<html>\n<head>\n");
  Win.document.write("<title>Sercan Treinamento e Consultoria - "+nome+"</title>\n");
  Win.document.write("<style type=\"text/css\">@import url(\"../css/estilos.css\");</style>\n");
  Win.document.write("</head>\n<body>\n");
  Win.document.write("<img src=\""+imagem+"\" width=\""+w+"\" height=\""+h+"\" />\n");
  Win.document.write("</body>\n</html>")
  Win.document.close();
}

function validarContato() {
  var passou = true;
  var alerta = "O sistema encontrou os seguintes erros no preenchimento do formulário:\n\n";

  // validações dos campos gerais
  if (document.getElementById("nome").value == "") {
	 passou = false; alerta += "- Nome preenchido incorretamente.\n";
  }
  if (document.contato.email.value == "") {
     passou = false; alerta += "- E-mail preenchido incorretamente.\n";
  }else{
      if (!validarEmail(document.contato.email.value)) {
           passou = false; alerta += "- E-mail preenchido incorretamente.\n";
      }
  }
  if (document.getElementById("telefone").value == "") {
	 passou = false; alerta += "- Telefone preenchido incorretamente. Utilize a forma: 00 0000.0000\n";
  }
  if (document.getElementById("assunto").value == "") {
	 passou = false; alerta += "- Assunto preenchido incorretamente.\n";
  }
  if (document.getElementById("comentarios").value == "") {
	 passou = false; alerta += "- Comentários preenchido incorretamente.\n";
  }
  if (document.getElementById("captcha").value == "") {
	 passou = false; alerta += "- Digite o código correspondente a imagem.\n";
  }

  if (passou == true) { return true; }
  else { alert(alerta); return false; }
}

function validarParceiros() {
  var passou = true;
  var alerta = "O sistema encontrou os seguintes erros no preenchimento do formulário:\n\n";

  // validações dos campos gerais
  if (document.getElementById("nome").value == "") {
	 passou = false; alerta += "- Nome preenchido incorretamente.\n";
  }
  if (document.parceiros.email.value == "") {
     passou = false; alerta += "- E-mail preenchido incorretamente.\n";
  }else{
      if (!validarEmail(document.parceiros.email.value)) {
           passou = false; alerta += "- E-mail preenchido incorretamente.\n";
      }
  }
  if (document.getElementById("telefone").value == "") {
	 passou = false; alerta += "- Telefone preenchido incorretamente. Utilize a forma: 00 0000.0000\n";
  }
  if (document.getElementById("assunto").value == "") {
	 passou = false; alerta += "- Assunto preenchido incorretamente.\n";
  }
  if (document.getElementById("comentarios").value == "") {
	 passou = false; alerta += "- Comentários preenchido incorretamente.\n";
  }
  if (document.getElementById("captcha").value == "") {
	 passou = false; alerta += "- Digite o código correspondente a imagem.\n";
  }

  if (passou == true) { return true; }
  else { alert(alerta); return false; }
}

function validarEmail(email)
{
	var s = email;
	var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) return true;
	if (filter.test(s))
	return true;
	else
	return false;
}
