function validar() 
{
  formulario = document.getElementById('faleconosco');
  var campos = new Array();
  email = document.getElementById('email');
  nome = document.getElementById('nome');
  logradouro = document.getElementById('logradouro');
  complemento = document.getElementById('complemento');
  tel_ddd = document.getElementById('tel_ddd');
  tel = document.getElementById('tel');

  var tipodoformulario = document.getElementById('tipodoformulario').value
if (tipodoformulario == 'faleconosco') {

cid = document.getElementById('cid');
cid_uf = document.getElementById('cid_uf');
mensagem = document.getElementById('mensagem');

 if (nome.value == '' || email.value == '' || tel_ddd.value == '' || tel.value == '' || cid.value == '' || cid_uf.value == '' || mensagem.value == '') {
      for(a = 0; a < formulario.length; a++){
        if(formulario.elements[a].type == "text" || formulario.elements[a].type == "textarea"){
           if(formulario.elements[a].value == "" && formulario.elements[a].name != "empresa" && formulario.elements[a].name != "comp" && formulario.elements[a].name != "mensagem"){
              formulario.elements[a].focus()
              break;
           }
        }
    }
    document.getElementById('validacao').style['display'] = 'block';
    document.getElementById('msgValidacao').innerHTML = 'Favor preencher todos os campos obrigatÃ³rios.';
    return false;
 }
 else{
//    document.getElementById('formuHTML').value = document.body.innerHTML
    formulario.submit();
 }
}
else if (tipodoformulario == 'demonstracao') {

  cidade = document.getElementById('cidade');
  estado = document.getElementById('estado');
  motivo = document.getElementById('motivoSelect');

 if (nome.value == '' || email.value == '' || logradouro.value == '' || complemento.value == '' || tel_ddd.value == '' || tel.value == '' || cidade.value == '' || estado.value == '' || motivo.value == 'Selecione' ) {
      for(a = 0; a < formulario.length; a++){
        if(formulario.elements[a].type == "text" || formulario.elements[a].type == "textarea"){
           if(formulario.elements[a].value == "" && formulario.elements[a].name != "empresa" && formulario.elements[a].name != "comp" && formulario.elements[a].name != "mensagem"){
              formulario.elements[a].focus()
              break;
           }
        }
    }
    document.getElementById('validacao').style['display'] = 'block';
    document.getElementById('msgValidacao').innerHTML = 'Favor preencher todos os campos obrigatÃ³rios.';
    return false;
 }
 else{
   // document.getElementById('formuHTML').value = document.body.innerHTML
    document.getElementById('motivo').value = motivo.value
    formulario.submit();
 }
}
}

function validaEmail(nomeCampo){
	var valor;
	valor = document.getElementById(nomeCampo).value;
	if(valor.length > 0){
		if(document.getElementById(nomeCampo).value=='&quot;&quot;' || document.getElementById(nomeCampo).value.indexOf('@')==-1 || document.getElementById(nomeCampo).value.indexOf('.')==-1 ){
			document.getElementById('validacao').style['display'] = 'block';
                        document.getElementById('msgValidacao').innerHTML = 'Favor preencher com um e-mail valido.';
			document.getElementById(nomeCampo).value = "";
			document.getElementById(nomeCampo).focus();
			return false;
		}else{
                document.getElementById('validacao').style['display'] = 'none';
                }
	}
}
function isNumber(numero){
   var valornumero;
   valornumero = document.getElementById(numero).value;

   for (i=0; i < valornumero.length; i++){
      var Caractere = numero.charAt(i);
      if(Caractere != "." && Caractere != "," && Caractere != "-"){
         if (isNaN(valornumero)){
			document.getElementById('validacao').style['display'] = 'block';
                        document.getElementById('msgValidacao').innerHTML = 'Favor preencher os campos de telefone somente com numeros.';
			document.getElementById(numero).value = "";
			document.getElementById(numero).focus();
                        return false;
         }
         else{
            document.getElementById('validacao').style['display'] = 'none';
            return false;
         }
      }
   }
}
