﻿
function EnviarFormContato()
{if(EmptyField(document.getElementById('assunto')))
{alert('Por favor informe o assunto.');document.getElementById('assunto').focus();return false;}
if(EmptyField(document.getElementById('nome')))
{alert('Por favor informe o nome para contato.');document.getElementById('nome').focus();return false;}
if(document.getElementById('estado').value=='0')
{alert('Por favor informe o Estado.');document.getElementById('estado').focus();return false;}
if(document.getElementById('cidade').value=='0')
{alert('Por favor informe a cidade.');document.getElementById('cidade').focus();return false;}
if(EmptyField(document.getElementById('email')))
{alert('Por favor informe o e-mail para contato.');document.getElementById('email').focus();return false;}
else
{if(!valida_email(document.getElementById('email')))
{alert('E-mail Inválido.');document.getElementById('email').focus();return false;}}
if(EmptyField(document.getElementById('fone')))
{alert('Por favor informe o Telefone/Fax para contato.');document.getElementById('fone').focus();return false;}
else
{if(!valida_telefone(document.getElementById('fone')))
{alert('Por favor siga o seguinte formato (XX) XXXX-XXXX.');document.getElementById('fone').focus();return false;}}
if(EmptyField(document.getElementById('comentario')))
{alert('Por favor informe o comentário do contato.');document.getElementById('comentario').focus();return false;}
var assunto_=document.getElementById('assunto').value;var nome_=document.getElementById('nome').value;var estado_=document.getElementById('estado').options[document.getElementById('estado').selectedIndex].text;var cidade_=document.getElementById('cidade').options[document.getElementById('cidade').selectedIndex].text;var email_=document.getElementById('email').value;var fone_=document.getElementById('fone').value;var comentario_=document.getElementById('comentario').value;if(!gestao_contatos.EnviarFormularioContato(assunto_,nome_,estado_,cidade_,email_,fone_,comentario_).value)
{document.getElementById('tb_erro').style.display="";document.getElementById('tb_erro').className="";document.getElementById('tb_sucesso').className="";document.getElementById('tb_formulario').className='';document.getElementById('tb_sucesso').style.display="none";document.getElementById('tb_formulario').style.display='none';}
else
{window.scrollTo(0,0);document.getElementById('tb_erro').style.display="none";document.getElementById('tb_sucesso').style.display="";document.getElementById('tb_formulario').style.display='none';document.getElementById('tb_erro').className="";document.getElementById('tb_sucesso').className="";document.getElementById('tb_formulario').className='';}}
function retorno_populaCidade(ret){var dt=ret.value;var cidade=document.getElementById('cidade');cidade.options.length=0;cidade.options[cidade.options.length]=new Option("Selecione uma Cidade","0");for(var i=0;i<dt.length;i++)
{cidade.options[cidade.options.length]=new Option(dt[i].Nome,dt[i].Codigo_Cidades);}
document.getElementById('img_cidade').style.display="none";}
function populaCidade(value)
{document.getElementById('img_cidade').style.display="";gestao_contatos.PopulaCidade(value,retorno_populaCidade);}
function EnterContato(evt)
{var charCode=(evt.which)?evt.which:event.keyCode;if(charCode==13)
{document.getElementById('bt_enviarContato').onclick();return false;}
return true;}