function chgpfpj(tipo){
  if (tipo == '0'){
    //PJuridica
     document.getElementById('psjuridica').style.visibility = 'visible';
     document.getElementById('psfisica').style.visibility = 'hidden';
     document.getElementById('psjuridica').style.height = "136px";
     document.getElementById('psfisica').style.height = "1px";
     document.getElementById('lnkpsj').style.textDecoration = "none";
     document.getElementById('lnkpsj').style.color = "#000000";
     document.getElementById('lnkpsf').style.color = "#000000";
     document.getElementById('selectpfj').style.backgroundImage = "url(/imgs/scrollcontact/palheta1_pfj.gif)";
  }else {
     document.getElementById('psjuridica').style.visibility = 'hidden';
     document.getElementById('psfisica').style.visibility = 'visible';
     document.getElementById('psfisica').style.height = "136px";
     document.getElementById('psjuridica').style.height = "1px";
     document.getElementById('lnkpsf').style.textDecoration = "none";
     document.getElementById('lnkpsf').style.color = "#000000";
     document.getElementById('lnkpsj').style.color = "#000000";
     document.getElementById('selectpfj').style.backgroundImage = "url(/imgs/scrollcontact/palheta2_pfj.gif)";
  }
}


function chgradios(tipo){
  if (tipo == '0'){
    //Portateis
     document.getElementById('portateisID').style.visibility = 'visible';
     document.getElementById('fixosID').style.visibility = 'hidden';
     document.getElementById('portateisID').style.height = "103px";
     document.getElementById('fixosID').style.height = "1px";
     document.getElementById('lnkpt').style.textDecoration = "none";
     document.getElementById('lnkfx').style.color = "#000000";
     document.getElementById('lnkpt').style.color = "#000000";
     document.getElementById('selectradios').style.backgroundImage = "url(/imgs/scrollcontact/palheta1.gif)";
  }else {
     document.getElementById('portateisID').style.visibility = 'hidden';
     document.getElementById('fixosID').style.visibility = 'visible';
     document.getElementById('fixosID').style.height = "103px";
     document.getElementById('portateisID').style.height = "1px";
     document.getElementById('lnkfx').style.textDecoration = "none";
     document.getElementById('lnkpt').style.color = "#000000";
     document.getElementById('lnkfx').style.color = "#000000";
     document.getElementById('selectradios').style.backgroundImage = "url(/imgs/scrollcontact/palheta2.gif)";
  }
}

function snd_scrollcontact(theform, serverPage, objID){
    var msg_usr = "<b>Por favor corrigir os campos! </b><br>";
    var erro = false;
    var nlinhas =2;

	var cep = Trim(document.formscrollcontact.cep.value);
	var c_cep = Trim(document.formscrollcontact.c_cep.value);
    var pjuridica =Trim(document.formscrollcontact.empresa.value);
    var pfisica =Trim(document.formscrollcontact.nome.value);

    if ((pjuridica=="") && (pfisica =="")){
       erro = true;nlinhas++; msg_usr = msg_usr + ">> Definir Empresa e Nome pessoa fisica <br>";
    }


    if ((Trim(document.formscrollcontact.email.value) == "") && (Trim(document.formscrollcontact.c_email.value) == "") ){
       erro = true;nlinhas++; msg_usr = msg_usr + ">> Campo EMAIL em branco   <br>";
    }else {
           if (Trim(document.formscrollcontact.email.value) != "") {
            if (!(email_valido = is_email(Trim(document.formscrollcontact.email.value)))) {
              erro = true;nlinhas++; msg_usr = msg_usr + ">> Email Comercial incorreto   <br>";
            }
           }
           if (Trim(document.formscrollcontact.c_email.value) != "") {
              if (!(email_valido = is_email(Trim(document.formscrollcontact.c_email.value)))) {
                erro = true;nlinhas++; msg_usr = msg_usr + ">> Email de Contato incorreto   <br>";
              }
           }
    }


	var mess = Trim(document.formscrollcontact.mensagem.value);

    var cpf = Trim(document.formscrollcontact.cpf.value);
    var cnpj = Trim(document.formscrollcontact.cnpj.value);

    if ( (cpf == "") && (cnpj == "")){
      erro = true;nlinhas++; msg_usr = msg_usr + ">> Campo CNPJ e CPF em branco   <br>";
    }else {
       if (cpf != ""){
          if (!(validacpf ('cpf'))) {
            erro = true;nlinhas++; msg_usr = msg_usr + ">> Campo CPF  incorreto   <br>";
          }
       }
       if (cnpj != ""){
          if (!(validaCNPJ ('cnpj'))) {
            erro = true;nlinhas++; msg_usr = msg_usr + ">> Campo CNPJ  incorreto   <br>";
          }
       }
    }

    if ((Trim(document.formscrollcontact.fone.value) == "") && (Trim(document.formscrollcontact.c_fone.value) == "") ){
        erro = true;nlinhas++; msg_usr = msg_usr + ">> Definir telefone <br>";
    }else {
        if (Trim(document.formscrollcontact.fone.value) != ""){
            if (Trim(document.formscrollcontact.fone_ddd.value) == ""){erro = true;nlinhas++; msg_usr = msg_usr + ">> Definir DDD Telefone Comercial   <br>";};
        }
        if (Trim(document.formscrollcontact.c_fone.value) != ""){
            if (Trim(document.formscrollcontact.c_fone_ddd.value) == ""){erro = true;nlinhas++; msg_usr = msg_usr + ">> Definir DDD Telefone Contato <br>";};
        }
    }

    if (!erro){
      if ( (cep=="") && (c_cep=="") ) {
        if (answer = confirm("O CEP e muito importante para nos, deseja enviar mensagem sem o CEP ?")){
            var str = getformvalues(theform);
            activateWaitingMessage ('btnscrollcontactsubmit',"")
            processajax ("POST",serverPage,objID, str);
        }
      }else {
            var str = getformvalues(theform);
            activateWaitingMessage ('btnscrollcontactsubmit',"")
            processajax ("POST",serverPage,objID, str);
      }
    }else {
        var areaAlert ='pnlalert';
        openAlertaWin ('300',nlinhas,areaAlert,'btnscrollcontactsubmit');
        activateWaitingMessage (areaAlert,"")
        var serverpage = "/app/base/alerta.php?nli="+nlinhas+"&msg="+msg_usr;
        processajax ("GET",serverpage,areaAlert,"");
    }
}


