try{
	ajax = new ActiveXObject("Microsoft.XMLHTTP");		
}catch(e){
	try{
		ajax = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(ex) {
           try {
			   ajax = new XMLHttpRequest();          
	       }catch(exc) {
    	       alert("Esse browser não tem recursos para uso do AJAX!!!");
			   ajax = null;     
           }
	}
}
var form = document.Form_Envio;
var arquivo = null;
var motivo = "informacoes";
var campos = [];
var relacao = [];
var perfil = [];
var arrMotivo = [];
var arrTemp = [];
var uf = null;
var tempPerfil = null;
//---------------------------------------------------------------
campos.push([0,"nome","Nome","O campo nome está em branco.\nPor favor, escreva seu nome."]);
campos.push([1,"empresa","Empresa","O campo Empresa está em branco.\nPor favor, escreva o nome da empresa."]);
campos.push([2,"pessoa","Contato","O campo Pessoa de Contato está em branco.\nPor favor, escreva o nome da pessoa de contato."]);
campos.push([3,"tecnologia","rdo_tecnologia","Por favor, escolha uma tecnologia."]);
campos.push([4,"email","vEmail","Por favor, digite um e-mail válido."]);
campos.push([5,"tel_celular","DDD_Cel","Por favor, escolha o DDD do celular.","Celular","O campo Celular está em branco.\nPor favor, escreva o número do celular."]);
campos.push([6,"tel_contato","DDD_Telefone_de_Contato","Por favor, escolha o DDD do telefone para contato.","Telefone_de_Contato","O campo Telefone de Contato está em branco.\nPor favor, escreva o número do telefone para contato."]);
campos.push([7,"div_cpf","CPF","Por favor, digite um CPF válido."]);
campos.push([8,"div_cnpj","CNPJ","Por favor, digite um CNPJ válido."]);
campos.push([9,"dados_fatura","vencimento_fatura","Por favor, digite um vencimento para sua fatura.","forma_pagamento","Por favor, escolha uma forma de pagamento."]);
campos.push([10,"canais",null]);
campos.push([11,"dados_canais","area_canal","Por favor, escolha um canal"]);
campos.push([12,"endereco","tipo_logradouro","Por favor, escolha uma tipo de logradouro.","vEndereco","O campo Endereço está em branco.\nPor favor, escreva o seu endereço.","bairro","O campo Bairro está em branco.\nPor favor, escreva o nome do seu bairro.","cep","Por favor, digite um CEP válido.","cidade","O campo Cidade está em branco.\nPor favor, escreva o nome da sua cidade."]);
campos.push([13,"div_rg","RG","Por favor, digite um RG válido."]);
//------------------------------------------
perfil.push([0,"vivo_pos",]);
perfil.push([1,"vivo_pre"]);
perfil.push([2,"vivo_empresas"]);
perfil.push([3,"acionista"]);
perfil.push([4,"investidor"]);
perfil.push([5,"nao_cliente"]);
//------------------------------------------
arrMotivo.push([0,"informacoes"]);
arrMotivo.push([1,"sugestoes"]);
arrMotivo.push([2,"reclamacoes"]);
arrMotivo.push([3,"elogios"]);
arrMotivo.push([4,"servicos"]);
//------------------------------------------
//relacao.push([perfil,motivo,campos...]);
//
relacao.push([0,0,3,0,4,5,7,10]);
relacao.push([0,1,6,0,4,6]);
relacao.push([0,2,3,0,4,5,6,7,10]);
relacao.push([0,3,0,4,5,6,7,10]);
relacao.push([0,4,3,0,4,5,6,9,7,12,10]);

relacao.push([1,0,3,0,4,5,6,7,13,10]);
relacao.push([1,1,0,4,5,6,7]);
relacao.push([1,2,3,0,4,5,6,7,13,10]);
relacao.push([1,3,0,4,5,6,7,13,10]);
relacao.push([1,4,3,0,4,5,6,12,10]);

relacao.push([2,0,3,1,2,4,5,6,8,10]);
relacao.push([2,1,1,2,4,5,6,8]);
relacao.push([2,2,1,2,4,5,6,8,10]);
relacao.push([2,3,1,2,4,5,6,8,10]);
relacao.push([2,4,1,2,4,5,6,8,12,9,10]);

relacao.push([3,0,0,4,6,7]);
relacao.push([3,1,0,4,6,7]);
relacao.push([3,2,0,4,6,7]);
relacao.push([3,3,0,4,6,7]);
relacao.push([3,4,0,4,6,7]);

relacao.push([4,0,0,4,6,7]);
relacao.push([4,1,0,4,6,7]);
relacao.push([4,2,0,4,6,7]);
relacao.push([4,3,0,4,6,7]);
relacao.push([4,4,0,4,6,7]);

relacao.push([5,0,0,4,6,7]);
relacao.push([5,1,0,4,6,7]);
relacao.push([5,2,0,4,6,7]);
relacao.push([5,3,0,4,6,7]);
//---------------------------------------------------------------
function monta_form(){
	var tPerfil;
	var tMotivo;
	var tCampos;
	arrTemp = [];
	for(var i in perfil){
		if(perfil[i][1]==arquivo){	
			tPerfil = perfil[i][0];
			break;
		} 
	}
	for(var i in arrMotivo){
		if(arrMotivo[i][1]==motivo){	
			tMotivo = arrMotivo[i][0];
			break;
		} 
	}
    for(var i in relacao){
       if(relacao[i][0]==tPerfil && relacao[i][1]==tMotivo){
			tCampos = i;
			break;
		}
		
    }
	for(var i in campos){
		for (var z in relacao[tCampos]){
			if (z>1){
				if (campos[i][0]==relacao[tCampos][z]){
					arrTemp.push(campos[i])
					if(campos[i][1].indexOf("tel_") !=-1){
						document.getElementById(campos[i][1]).style.display = "block";
					}else{
						document.getElementById(campos[i][1]).style.display = "inline";
					}					
					break;
				}else{
					document.getElementById(campos[i][1]).style.display = "none";
				}
			}
		}
	}
}
function ajaxMonta(url,metodo,elemento,variaveis){
	objDiv = elemento;
	ajax.open(metodo,url,true);
	ajax.setRequestHeader("Content-Type", "text/xml");
	ajax.onreadystatechange = function(){
		if (ajax.readyState == 4 ) {
			montaConteudo(ajax.responseXML,elemento);
		}else if(ajax.readyState == 1 ){
			 objDiv.options[0] = new Option("Aguarde....","");
		}
	}
	ajax.send(variaveis);
}
function montaConteudo(conteudo,elemento){
	objDiv = elemento;
	for (i=0;i<objDiv.options.length;i++){
		//objDiv.options.remove(i);
		objDiv.options[i] = null;
		objDiv.options[i+1] = null;
	}


	if (elemento.name.indexOf("Detalhes")!=-1){
		var vAssunto = conteudo.getElementsByTagName("item");
	}else{
		var vAssunto = conteudo.getElementsByTagName("assunto");
	}

	if(vAssunto.length > 2){	// Valor default 0
		objDiv.style.visibility = "visible";
		for (var i = 0 ; i < vAssunto.length ; i++){
			var pAssunto = vAssunto[i];
			if (elemento.name.indexOf("Detalhes")!=-1){
				vId = pAssunto.attributes.getNamedItem("title").value
				textoIni = "Detalhes do assunto";
			}else{
				vId = pAssunto.attributes.getNamedItem("id").value;
				textoIni = "Selecione o assunto";
			}
			vTitulo = pAssunto.attributes.getNamedItem("title").value
			objDiv.options[i] = new Option(vTitulo,vId);
		}
		objDiv.options[0] = new Option(textoIni,"");
		objDiv.selectedIndex = 0;
	}else{
		objDiv.style.visibility = "hidden";
		objDiv.selectedIndex = 0;
	}
}
function sForm(e){
	valor = e.value;
	if("outros"==valor.toLowerCase()){
		document.getElementById("txtAssunto").style.display = "block";
	}else{
		document.getElementById("txtAssunto").style.display = "none";
	}
}
function showForm(e){
	valor = e.value;
	if("outros"==valor.toLowerCase()){
		document.getElementById("txtAssunto").style.display = "block";
	}else{
		document.getElementById("txtAssunto").style.display = "none";
	}
	
	url = "/faleconosco_pop/webservice.php";
	if (e.name.indexOf("Perfil")!=-1){
		arquivo = valor;
		if (motivo!=null){
			tempPerfil = arquivo;
			variaveis = "motivo="+motivo+"&assunto=null&arquivo="+arquivo+".xml";
			url = url +"?"+variaveis;		
			ajaxMonta(url,'get',document.Form_Envio.Assunto,null);
			monta_form();
			document.Form_Envio.Detalhes.selectedIndex = 0;
		}
	}else if(e.name.indexOf("Motivo")!=-1 && arquivo != null){
		motivo = valor.replace("motivo_","");
		variaveis = "motivo="+motivo+"&assunto=null&arquivo="+arquivo+".xml";
		url = url +"?"+variaveis;		
		ajaxMonta(url,'get',document.Form_Envio.Assunto,null);
		monta_form();
		document.Form_Envio.Detalhes.selectedIndex = 0;
	}else if(e.name.indexOf("Assunto")!=-1 && arquivo != null){
		variaveis = "motivo="+motivo+"&assunto="+valor+"&arquivo="+arquivo+".xml";
		url = url +"?"+variaveis;
		ajaxMonta(url,'get',document.Form_Envio.Detalhes,null);
	}
	if (arquivo=="nao_cliente"){
		document.getElementById("motivo_ser").style.display = "none";
		document.getElementById("motivo_ser_vazio").style.display = "inline";
	}else{
		document.getElementById("motivo_ser_vazio").style.display = "none";
		document.getElementById("motivo_ser").style.display = "inline";
	}
	if (arquivo=="nao_cliente" && motivo == "servicos"){
		document.Form_Envio.Motivo[0].checked =true;
		motivo = "informacoes";
		showForm(e);
	}
}
function loadDDD(estado){
	var oCampo;
	oCampo = document.Form_Envio.DDD_Telefone_de_Contato;
	oCampo2 = document.Form_Envio.DDD_Cel;
	oCampo.options.length = 0;
	oCampo2.options.length = 0;
	oCampo[0]=new Option("---","");
	oCampo2[0]=new Option("---","");
	switch(estado){
		case "SP":
			oCampo[1]=new Option("11","11");
			oCampo[2]=new Option("12","12");
			oCampo[3]=new Option("13","13");
			oCampo[4]=new Option("14","14");
			oCampo[5]=new Option("15","15");
			oCampo[6]=new Option("16","16");
			oCampo[7]=new Option("17","17");
			oCampo[8]=new Option("18","18");
			oCampo[9]=new Option("19","19");
			break; 
		case "RJ":
			oCampo[1]=new Option("21","21");
			oCampo[2]=new Option("22","22");
			oCampo[3]=new Option("24","24");
			break;
		case "ES":
			oCampo[1]=new Option("27","27");
			oCampo[2]=new Option("28","28");
			break;
		case "PR":
			oCampo[1]=new Option("41","41");
			oCampo[2]=new Option("42","42");
			oCampo[3]=new Option("43","43");
			oCampo[4]=new Option("44","44");
			oCampo[5]=new Option("45","45");
			oCampo[6]=new Option("46","46");
			break;
		case "SC":
			oCampo[1]=new Option("47","47");
			oCampo[2]=new Option("48","48");
			oCampo[3]=new Option("49","49");
			break;
		case "RS":
			oCampo[1]=new Option("51","51");
			oCampo[2]=new Option("53","53");
			oCampo[3]=new Option("54","54");
			oCampo[4]=new Option("55","55");
			break;
		case "DF":
			oCampo[1]=new Option("61","61");
			break;
		case "GO":
			oCampo[1]=new Option("62","62");
			oCampo[2]=new Option("64","64");
			break;
		case "TO":
			oCampo[1]=new Option("63","63");
			break;
		case "MT":
			oCampo[1]=new Option("65","65");
			oCampo[2]=new Option("66","66");
			break;
		case "MS":
			oCampo[1]=new Option("67","67");
			break;
		case "AC":
			oCampo[1]=new Option("68","68");
			break;
		case "RO":
			oCampo[1]=new Option("69","69");
			break;
		case "BA":
			oCampo[1]=new Option("71","71");
			oCampo[2]=new Option("73","73");
			oCampo[3]=new Option("74","74");
			oCampo[4]=new Option("75","75");
			oCampo[5]=new Option("77","77");
			break;
		case "SE":
			oCampo[1]=new Option("79","79");
			break;
		case "PA":
			oCampo[1]=new Option("91","91");
			oCampo[2]=new Option("93","93");
			oCampo[3]=new Option("94","94");
			break;
		case "AM":
			oCampo[1]=new Option("92","92");
			oCampo[2]=new Option("97","97");
			break;
		case "RO":
			oCampo[1]=new Option("95","95");
			break;
		case "AP":
			oCampo[1]=new Option("96","96");
			break;
		case "MA":
			oCampo[1]=new Option("98","98");
			oCampo[2]=new Option("99","99");
			break;
		case "CE":
		case "PE":	
			oCampo[1]=new Option("81","81");
			oCampo[2]=new Option("82","82");
			oCampo[3]=new Option("83","83");
			oCampo[4]=new Option("84","83");
			oCampo[5]=new Option("85","84");
			oCampo[6]=new Option("86","85");
			break;			
	}
	switch(estado){
		case "SP":
			oCampo2[1]=new Option("11","11");
			oCampo2[2]=new Option("12","12");
			oCampo2[3]=new Option("13","13");
			oCampo2[4]=new Option("14","14");
			oCampo2[5]=new Option("15","15");
			oCampo2[6]=new Option("16","16");
			oCampo2[7]=new Option("17","17");
			oCampo2[8]=new Option("18","18");
			oCampo2[9]=new Option("19","19");
			break; 
		case "RJ":
			oCampo2[1]=new Option("21","21");
			oCampo2[2]=new Option("22","22");
			oCampo2[3]=new Option("24","24");
			break;
		case "ES":
			oCampo2[1]=new Option("27","27");
			oCampo2[2]=new Option("28","28");
			break;
		case "PR":
			oCampo2[1]=new Option("41","41");
			oCampo2[2]=new Option("42","42");
			oCampo2[3]=new Option("43","43");
			oCampo2[4]=new Option("44","44");
			oCampo2[5]=new Option("45","45");
			oCampo2[6]=new Option("46","46");
			break;
		case "SC":
			oCampo2[1]=new Option("47","47");
			oCampo2[2]=new Option("48","48");
			oCampo2[3]=new Option("49","49");
			break;
		case "RS":
			oCampo2[1]=new Option("51","51");
			oCampo2[2]=new Option("53","53");
			oCampo2[3]=new Option("54","54");
			oCampo2[4]=new Option("55","55");
			break;
		case "DF":
			oCampo2[1]=new Option("61","61");
			break;
		case "GO":
			oCampo2[1]=new Option("62","62");
			oCampo2[2]=new Option("64","64");
			break;
		case "TO":
			oCampo2[1]=new Option("63","63");
			break;
		case "MT":
			oCampo2[1]=new Option("65","65");
			oCampo2[2]=new Option("66","66");
			break;
		case "MS":
			oCampo2[1]=new Option("67","67");
			break;
		case "AC":
			oCampo2[1]=new Option("68","68");
			break;
		case "RO":
			oCampo2[1]=new Option("69","69");
			break;
		case "BA":
			oCampo2[1]=new Option("71","71");
			oCampo2[2]=new Option("73","73");
			oCampo2[3]=new Option("74","74");
			oCampo2[4]=new Option("75","75");
			oCampo2[5]=new Option("77","77");
			break;
		case "SE":
			oCampo2[1]=new Option("79","79");
			break;
		case "PA":
			oCampo2[1]=new Option("91","91");
			oCampo2[2]=new Option("93","93");
			oCampo2[3]=new Option("94","94");
			break;
		case "AM":
			oCampo2[1]=new Option("92","92");
			oCampo2[2]=new Option("97","97");
			break;
		case "RO":
			oCampo2[1]=new Option("95","95");
			break;
		case "AP":
			oCampo2[1]=new Option("96","96");
			break;
		case "MA":
			oCampo2[1]=new Option("98","98");
			oCampo2[2]=new Option("99","99");
			break;
		case "CE":
		case "PE":		
			oCampo2[1]=new Option("81","81");
			oCampo2[2]=new Option("82","82");
			oCampo2[3]=new Option("83","83");
			oCampo2[4]=new Option("84","83");
			oCampo2[5]=new Option("85","84");
			oCampo2[6]=new Option("86","85");
			break;				
	}
	document.Form_Envio.estado.value = estado;
}
function contaChars(objText, objCount){
	if(objText.value.length > 2048){
		alert("Você atingiu o limite máximo de caracteres permitidos.");
		objText.value = objText.value.substr(0, 2048);
	}
	objCount.value = objText.value.length;	
}
function validaForm(){	

	if(
	   	document.getElementById("rdo_perfil_pos").checked == false &&
		document.getElementById("rdo_perfil_pre").checked == false &&
		document.getElementById("rdo_perfil_emp").checked == false &&
		document.getElementById("rdo_perfil_acn").checked == false &&
		document.getElementById("rdo_perfil_inv").checked == false &&
		document.getElementById("rdo_perfil_ncl").checked == false
	){
		alert("Por favor, selecione um Perfil do usuário.");
		return false;
	}
	
	if(
	   	document.getElementById("rdo_motivo_inf").checked == false &&
		document.getElementById("rdo_motivo_sug").checked == false &&
		document.getElementById("rdo_motivo_rec").checked == false &&
		document.getElementById("rdo_motivo_elo").checked == false &&
		document.getElementById("rdo_motivo_ser").checked == false
	){
		alert("Por favor, selecione o motivo.");
		return false;
	}
	
	if (document.Form_Envio.Regiao.value == 0){
		alert("Por favor, escolha um estado.");
		document.Form_Envio.Regiao.focus();
		return false;
	}
	if (document.Form_Envio.Assunto.value == 0){
		alert("Por favor, escolha um assunto.");
		document.Form_Envio.Assunto.focus();
		return false;
	}
	
	if (document.getElementById("slc_detalhes_assunto").style.visibility != "hidden"){
		if(document.Form_Envio.Detalhes.value == ""){
			alert("Por favor, escolha o detalhe do assunto.");
			return false;
		}
	}
	
	if(
	   	document.getElementById("rdo_perfil_pos").checked == true ||
		document.getElementById("rdo_perfil_pre").checked == true
		){
		if(
		   document.getElementById("rdo_motivo_inf").checked == true ||
		   document.getElementById("rdo_motivo_rec").checked == true ||
		   document.getElementById("rdo_motivo_ser").checked == true
		   ){
			if(
				document.getElementById("rdo_tecnologia_cdma").checked == false &&
				document.getElementById("rdo_tecnologia_gsm").checked == false
				){
					alert("Por favor, selecione uma tecnologia.");
					return false;
			}
		}
	}else if(document.getElementById("rdo_perfil_emp").checked == true){
		if(document.getElementById("rdo_motivo_inf").checked == true){
			if(
				document.getElementById("rdo_tecnologia_cdma").checked == false &&
				document.getElementById("rdo_tecnologia_gsm").checked == false
				){
					alert("Por favor, selecione uma tecnologia.");
					return false;
			}
		}
	}
	
	if(document.getElementById("empresa").style.display != "none"){
		if(document.getElementById("tEmpresa").value == ""){
			alert("Por favor, preencha o campo Empresa.");
			document.getElementById("tEmpresa").focus();
			return false;
		}
	}
	if(document.getElementById("pessoa").style.display != "none"){
		if(document.getElementById("pContato").value == ""){
			alert("Por favor, preencha o campo Pessoa de Contato.");
			document.getElementById("pContato").focus();
			return false;
		}
	}
	
	for (var y in arrTemp){
		for (z=2; z < arrTemp[y].length; z++){
			if ((z % 2)==0 && arrTemp[y][z] != "rdo_tecnologia"){
				e = document.Form_Envio[arrTemp[y][z]];
				if (!e == false){
					if(e.tagName=="INPUT"){
						if(e.type=="text"){
							if(e.name == "Nome"){
								if(document.getElementById("realname").value == ""){
									alert("Por favor, preencha o Nome.");
									document.getElementById("realname").focus();
									return false;
								}
							}else if (e.name == "vEmail"){
									if(Trim(e.value) == ""){
										alert("Preencha o E-Mail!");
										e.focus();
										return false;
									}
									var goodEmail = e.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
									if (!goodEmail){
										alert("E-Mail inválido!")
										e.focus();
										return false;
									}
							}else if(e.name == "CPF"){
								v = e;
								st = v.value;
								if (st == ""){
									alert("Preencha o CPF!");
									v.focus();
									return (false);
								}
								l = st.length;
								st2 = "";
								for (i = 0; i < l; i++) {
									caracter = st.substring(i,i+1);
									if ((caracter >= '0') && (caracter <= '9'));
										st2 = st2 + caracter;
								}
								if ((st2.length > 11) || (st2.length < 10)){
									alert("O número de caracteres deste CPF precisa ser igual a 11!");
									v.focus();
									return (false);
								}
								if (st2.length==10)
									st2 = '0' + st2;
								digito1 = st2.substring(9,10);
								digito2 = st2.substring(10,11);
								digito1 = parseInt(digito1,10);
								digito2 = parseInt(digito2,10);
								sum = 0; mul = 10;
								for (i = 0; i < 9 ; i++) {
									digit = st2.substring(i,i+1);
									tproduct = parseInt(digit ,10) * mul;
									sum += tproduct;
									mul--;
								}
								dig1 = ( sum % 11 );
								if ( dig1==0 || dig1==1 )
									dig1=0;
								else
									dig1 = 11 - dig1;
								if (dig1!=digito1){
									alert("Número de CPF inválido!")
									v.focus();
									return (false);
								}
								sum = 0;
								mul = 11;
								for (i = 0; i < 10 ; i++) {
									digit = st2.substring(i,i+1);
									tproduct = parseInt(digit ,10)*mul;
									sum += tproduct;
									mul--;
								}
								dig2 = (sum % 11);
								if ( dig2==0 || dig2==1 )
									dig2=0;
								else
									dig2 = 11 - dig2;  
								if (dig2 != digito2){
									alert("Número de CPF inválido!");
									v.focus();
									return (false);
								}
							}else{
								/*if(Trim(e.value)==""){
									alert(arrTemp[y][z+1]);
									e.focus();
									return (false);
								}	*/
							}
						}
					}else{
						/*if(Trim(e.value)==""){
							alert(arrTemp[y][z+1]);
							e.focus();
							return (false);
						}	*/
					}
				}
			}
		}
	}
	
	if(document.getElementById("div_cnpj").style.display != "none"){
		var cnpj = document.getElementById("cnpj").value;
		var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
		digitos_iguais = 1;
		if (cnpj.length < 14 && cnpj.length > 15) {
			alert("Por favor, preencha um CNPJ válido.");
			document.getElementById("cnpj").focus();
			return false;
		}
		for (i = 0; i < cnpj.length - 1; i++)
			if (cnpj.charAt(i) != cnpj.charAt(i + 1))
				  {
				  digitos_iguais = 0;
				  break;
				  }
		if (!digitos_iguais)
			{
			tamanho = cnpj.length - 2
			numeros = cnpj.substring(0,tamanho);
			digitos = cnpj.substring(tamanho);
			soma = 0;
			pos = tamanho - 7;
			for (i = tamanho; i >= 1; i--)
				  {
				  soma += numeros.charAt(tamanho - i) * pos--;
				  if (pos < 2)
						pos = 9;
				  }
			resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
			if (resultado != digitos.charAt(0)) {
				alert("Por favor, preencha um CNPJ válido.");
				document.getElementById("cnpj").focus();
				return false;
			}
			tamanho = tamanho + 1;
			numeros = cnpj.substring(0,tamanho);
			soma = 0;
			pos = tamanho - 7;
			for (i = tamanho; i >= 1; i--)
				  {
				  soma += numeros.charAt(tamanho - i) * pos--;
				  if (pos < 2)
						pos = 9;
				  }
			resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
			if (resultado != digitos.charAt(1)) {
				alert("Por favor, preencha um CNPJ válido.");
				document.getElementById("cnpj").focus();
				return false;
			}
			//return true;
			}
		else {
			alert("Por favor, informe o CNPJ.");
			document.getElementById("cnpj").focus();
			return false;
		}
	}
	
	if(document.getElementById("div_rg").style.display != "none"){
		if(document.getElementById("rg").value == ""){
			alert("Por favor, preencha o RG.");
			document.getElementById("rg").focus();
			return false;
		}
	}
	
	if(document.getElementById("tel_celular").style.display != "none"){
		if(document.getElementById("ddd_cel").value == "" || document.getElementById("celular").value.length < 8){
			alert("Por favor, preencha o DDD e o Celular.");
			document.getElementById("ddd_cel").focus();
			return false;
		}
	}
	
	if(document.getElementById("tel_contato").style.display != "none"){
		if(document.getElementById("ddd_tel").value == "" || document.getElementById("tel").value.length < 8){
			alert("Por favor, preencha o DDD e o Telefone.");
			document.getElementById("ddd_tel").focus();
			return false;
		}
	}
	
	if(document.getElementById("dados_fatura").style.display != "none"){
		if(document.getElementById("rdo_motivo_ser").checked == true){
			if(document.getElementById("vencimento_fatura").value.length == 0){
				alert("Por favor, digite um vencimento para sua fatura.");
				return false;
			}
		}
		if(
			document.getElementById("forma_pagamento").checked == false &&
			document.getElementById("forma_pagamento2").checked == false
		){
			alert("Por favor, selecione uma Forma de pagamento.");
			return false;
		}
	}
	
	if(document.getElementById("canais").style.display != "none"){
		if(
		   document.getElementById("reincidencia").checked == false &&
		   document.getElementById("reincidencia2").checked == false
		){
			alert("Por favor, responda a pergunta.");
			return false;
		}
		if (document.getElementById("dados_canais").style.display != "none"){
			if (document.Form_Envio.area_canal.value == ""){
				alert("Por favor, escolha um canal.");
				return false;	
			}
		}
	}

	if(document.getElementById("endereco").style.display != "none"){
		if(document.getElementById("tipo_logradouro").value == ""){
			alert("Por favor, escolha o tipo do logradouro.");
			document.getElementById("tipo_logradouro").focus();
			return false;
		}
		
		if(document.getElementById("vendereco").value == ""){
			alert("Por favor, informe o endereço.");
			document.getElementById("vendereco").focus();
			return false;
		}
		if(document.getElementById("complemento").value == ""){
			alert("Por favor, informe o complemento.");
			document.getElementById("complemento").focus();
			return false;
		}
		if(document.getElementById("bairro").value == ""){
			alert("Por favor, informe o bairro.");
			document.getElementById("bairro").focus();
			return false;
		}
		if(document.getElementById("cep").value == ""){
			alert("Por favor, informe o cep.");
			document.getElementById("cep").focus();
			return false;
		}
		if(document.getElementById("cidade").value == ""){
			alert("Por favor, informe o cidade.");
			document.getElementById("cidade").focus();
			return false;
		}
		if(document.getElementById("estado").value == ""){
			alert("Por favor, informe o estado.");
			document.getElementById("estado").focus();
			return false;
		}
	}
	
	if (document.Form_Envio.ncl_comentarios.value == ""){
		alert("Por favor, digite uma mensagem.");
		document.Form_Envio.ncl_comentarios.focus();
		return false;	
	}
	
	document.Form_Envio.mail_from.value = document.Form_Envio.vEmail.value;
	document.Form_Envio.subject.value = document.Form_Envio.Assunto.value;
	
	
	if (tempPerfil=="vivo_pos"){
		document.Form_Envio.pre_ddd_cel.value = "";
		document.Form_Envio.pre_celular.value = "";
		
		document.Form_Envio.pos_ddd_cel.value = document.Form_Envio.DDD_Cel.value;
		document.Form_Envio.pos_celular.value = document.Form_Envio.Celular.value;
		
		document.Form_Envio.DDD_Cel.value = "";
		document.Form_Envio.Celular.value = "";
	}else if (tempPerfil=="vivo_pre"){
		document.Form_Envio.pos_ddd_cel.value = "";
		document.Form_Envio.pos_celular.value = "";
		
		document.Form_Envio.pre_ddd_cel.value = document.Form_Envio.DDD_Cel.value;
		document.Form_Envio.pre_celular.value = document.Form_Envio.Celular.value;
		
		document.Form_Envio.DDD_Cel.value = "";
		document.Form_Envio.Celular.value = "";
	}else{
		document.Form_Envio.pre_ddd_cel.value = "";
		document.Form_Envio.pre_celular.value = "";
		
		document.Form_Envio.pos_ddd_cel.value = document.Form_Envio.DDD_Cel.value;
		document.Form_Envio.pos_celular.value = document.Form_Envio.Celular.value;
		
		document.Form_Envio.DDD_Cel.value = "";
		document.Form_Envio.Celular.value = "";
	}
	//--- Alerta de enviando
	var v = document.createElement('div');
		v.setAttribute('id', 'enviando');
		v.className = 'enviando';
		document.body.appendChild(v);

	var i = document.createElement('p');
		i.setAttribute('className', 'texto_azul');
		i.innerHTML = "Aguarde. <br> Enviando seus dados para o fale conosco.";
		document.getElementById("enviando").appendChild(i);

	document.getElementById("formulario").style.display = "none";
	document.getElementById('IdColuna_esquerda').style.height="500px";

	return true;
}
/*function pegaEstado(v){
	if (v !="null" && v != null){
		uf = v;
		objDiv =document.Form_Envio.Regiao;
		for (i=0;i<objDiv.options.length;i++){
			if (objDiv.options[i].value == v){
				objDiv.selectedIndex = i;
				break;
			}
		}
		loadDDD(v)
	}
}*/
function Trim(s){
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')){
		s = s.substring(1,s.length);
	}
	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')){
		s = s.substring(0,s.length-1);
	}
	return s;
}

function twPlanosOff(vID){
	//alert(vID.value);
	var chk = document.getElementById('rdo_perfil_pos').checked;
	if((vID=='CE' || vID=='PE') && chk){
		document.getElementById('chkpos').style.display="none";
	}else{
		document.getElementById('chkpos').style.display="block";
	}	
}

