function avaliacaoPasso(passo, vindode, total)
{
  if (vindode==2 && passo == 3)
  {
    if (avaliacaoEnviarDadosEmpresa() == false) {passo = 2;};
  }

  if (vindode==3 && passo == 4)
  {
    if (avaliacaoEnviarDadosColaboradores() == false) {passo = 3;};
  }

  if(vindode==2 && passo==3)
  {
    geraFormColaboradores();
  }

  for (i=1;i<=total;i++)
  {
    t  = 'passo' + i;
    tl = 'passo' + i + 'legend';
    if(passo == i)
    {
      document.getElementById(t).style.display ='block';
      document.getElementById(tl).className ='tabLegendEnable';
    } else {
      document.getElementById(t).style.display ='none';
      document.getElementById(tl).className ='tabLegendDisable';
    }
  }
} 

function geraFormColaboradores()
{
  qde = document.formavaliacao.qde_colaboradores.value;
  var colaboradores = '';

  for(i = 1; i <= qde; i++)
  {

  colaboradores = colaboradores + 
'      <div class="VFormColumnDiv" style="border:1px solid #ccc"> ' + "\n" +
'      <h5>Colaborador ' + i + '</h5>' + "\n" +
'      <ul>' + "\n" +
'        <li>' + "\n" +
'          <label for="pus_nome">Nome</label>' + "\n" +
'          <div class="field">' + "\n" +
'            <input style="width:200px" maxlenght="50" type="text" name="prsusuario[' + i + '][pus_nome]" id="pus_nome' + i + '" />' + "\n" +
'          </div>' + "\n" +
'          <br />' + "\n" +
'        </li>' + "\n" +
'        <li>' + "\n" +
'          <label for="pus_cargo_empresa">Cargo na Empresa</label>' + "\n" +
'          <div class="field">' + "\n" +
'            <select name="prsusuario[' + i + '][pus_cargo_empresa]" id="pus_cargo_empresa' + i + '">' + "\n" +
'              <option value="-">-- selecione --</option>' + "\n" +
'              <option value="Diretor">Diretor</option>' + "\n" +
'              <option value="Gerente de Filial">Gerente de Filial</option>' + "\n" +
'              <option value="Gerente de Vendas">Gerente de Vendas</option>' + "\n" +
'              <option value="Supervisor de Vendas">Supervisor de Vendas</option>' + "\n" +
'              <option value="Vendedor">Vendedor</option>' + "\n" +
'              <option value="Atendente Pós-Venda">Atendente Pós-Venda</option>' + "\n" +
'              <option value="Administrativo">Administrativo</option>' + "\n" +
'            </select>' + "\n" +
'          </div>' + "\n" +
'          <br />' + "\n" +
'        </li>' + "\n" +
'        <li>' + "\n" +
'          <label for="pus_email">Email</label>' + "\n" +
'          <div class="field">' + "\n" +
'            <input style="width:200px" maxlenght="30" type="text" name="prsusuario[' + i + '][pus_email]" id="pus_email' + i + '" />' + "\n" +
'          </div>' + "\n" +
'          <br />' + "\n" +
'        </li>' + "\n" +
'      </ul>' + "\n" +
'      </div><!-- VFormColumnDiv -->' + "\n\n" ;

  } // for(i = 1; i <= qde; i++)
  
//  alert(colaboradores);
  meudiv = document.getElementById('colaboradores');
  meudiv.innerHTML = colaboradores;
}

function avaliacaoEnviarDadosEmpresa()
{
  var ok = true;
	var msgerro = '';

	if (document.formavaliacao.prs_razsocial.value == '') { ok = false; msgerro += "Informe a Razão Social\n";}
	if (document.formavaliacao.prs_nome_fantasia.value == '') { ok = false; msgerro += "Informe o Nome Fantasia\n";}
	if (document.formavaliacao.prs_cpfcnpj.value == '') { ok = false; msgerro += "Informe o CNPJ\n";}
	if (document.formavaliacao.prs_email.value == '') { ok = false; msgerro += "Informe o Email\n";}
	if (document.formavaliacao.prs_end_bairro.value == '') { ok = false; msgerro += "Informe o Endereço\n";}
	if (document.formavaliacao.prs_end_bairro.value == '') { ok = false; msgerro += "Informe o Bairro\n";}
	if (document.formavaliacao.prs_end_cidade.value == '') { ok = false; msgerro += "Informe a Cidade\n";}
	if (document.formavaliacao.prs_end_uf.value == '-') { ok = false; msgerro += "Informe a Unidade da Federação (UF)\n";}
	if (document.formavaliacao.prs_end_cep.value == '') { ok = false; msgerro += "Informe o CEP\n";}
	if (document.formavaliacao.prs_fone.value == '') { ok = false; msgerro += "Informe o Fone\n";}
	if (document.formavaliacao.prs_res_empresa.value == '') { ok = false; msgerro += "Informe o Nome do Responsável\n";}
	if (document.formavaliacao.prs_res_email.value == '') { ok = false; msgerro += "Informe o Email do Responsável\n";}
	if (document.formavaliacao.prs_res_cpf.value == '') { ok = false; msgerro += "Informe o CPF do Responsável\n";}

	if (ok == false) {
		alert(msgerro);
	}

  return ok;
}	

function avaliacaoEnviarDadosColaboradores()
{
  var ok = true;
	var msgerro = '';

  qde = document.formavaliacao.qde_colaboradores.value;
  for(i = 1; i <= qde; i++)
  {
	  if (document.getElementById('pus_nome' + i).value == '') { ok = false; msgerro += "Informe Nome do Colaborador" + i + "\n";}
	  if (document.getElementById('pus_cargo_empresa' + i).value == '-') { ok = false; msgerro += "Informe o Cargo do Colaborador " + i + "\n";}
	  if (document.getElementById('pus_email' + i).value == '') { ok = false; msgerro += "Informe o Email do Colaborador " + i + "\n";}
  }
	if (ok == false) {
		alert(msgerro);
	}

  return ok;
}	


function avaliacaoEnviar()
{
  if (avaliacaoEnviarDadosEmpresa() && avaliacaoEnviarDadosColaboradores())
  {
    document.formavaliacao.submit();
  }
}

function assovebaMostra()
{
  document.getElementById('assoveba').style.display ='block';
}
