function jsAjaxCadastroClienteSalvar(){

	//Validação Javascript
	var bcdServico			= ($Id('cdServico').value != '' );
	var bnmCliente			= ($Id('nmCliente').value.search(/^[A-Za-zÀ-ú ]{3,70}$/gi) == 0);
	var bdmTipoPessoa		= ($Id('dmTipoPessoa').value != '' );
	var bnmRepresentante	= (($Id('dmTipoPessoa').value == 'F' && $Id('nmRepresentante').value == '') || ($Id('dmTipoPessoa').value == 'J' && $Id('nmRepresentante').value.search(/^[A-Za-zÀ-ú ]{3,70}$/gi) == 0) );
	var bcdCidade			= ($Id('cdCidade').value != '' );
	var bcdBairro			= ($Id('cdBairro').value != '' );
	var bcdTema				= ($Id('cdTema').value != '' );
	var bnmLogradouro		= ($Id('nmLogradouro').value.search(/^.{2,100}$/gi) == 0);
	var bnuResidencia		= ($Id('nuResidencia').value != '' );
	var bnuCEP				= ($Id('nuCEP').value != '' );
	var bsgEstado			= ($Id('sgEstado').value != '' );
	var bnmReferencia		= (($Id('nmReferencia').value == '') || ($Id('nmReferencia').value.search(/^[A-Za-zÀ-ú ]{3,70}$/gi) == 0));
	var bnuTelefonePre		= ($Id('nuTelefonePre').value.search(/^[1-9][0-9]$/) == 0);
	var bnuTelefone			= ($Id('nuTelefone').value.search(/^\d{8}$/) == 0);
	var bedEmail			= ($Id('edEmail').value.search(/^[a-zA-Z0-9_.-]{2,}@[a-zA-Z0-9_.-]+\.([a-zA-Z]{2,4})$/) == 0);
	var bnuCpf				= ((($Id('dmTipoPessoa').value == 'F') && ($Id('nuCpf').value != '')) || (($Id('dmTipoPessoa').value == 'J') && ($Id('nuCpf').value == '')))
	var bnuCnpj				= ((($Id('dmTipoPessoa').value == 'J') && ($Id('nuCnpj').value != '')) || (($Id('dmTipoPessoa').value == 'F') && ($Id('nuCnpj').value == '')))
	var bnuRG				= (($Id('nuRG').value != '') && ($Id('nuRG').value != 'RG/Insc.Estadual*'))

	if(xmlhttp && bcdServico && bnmCliente && bdmTipoPessoa && bnmRepresentante && bcdCidade && bcdBairro && bcdTema && bnmLogradouro && bnuResidencia && bnuCEP && bsgEstado && bnmReferencia && bnuTelefonePre && bnuTelefone && bedEmail && bnuCpf && bnuCnpj && bnuRG){
		jsCarregando(1);

		//Abre a url
		xmlhttp.open('GET', 'bin/AjaxCadastroCliente.asp?op=1&cdServico=' + $Id('cdServico').value + '&nmCliente=' + $Id('nmCliente').value + '&dmTipoPessoa=' + $Id('dmTipoPessoa').value + '&nmRepresentante=' + $Id('nmRepresentante').value + '&cdCidade=' + $Id('cdCidade').value + '&cdBairro=' + $Id('cdBairro').value + '&cdTema=' + $Id('cdTema').value + '&nmLogradouro=' + $Id('nmLogradouro').value + '&AcessoDisponivel=' + $Id('AcessoDisponivel').value + '&nuResidencia=' + $Id('nuResidencia').value + '&dsComplemento=' + $Id('dsComplemento').value + '&nuCEP=' + $Id('nuCEP').value + '&sgEstado=' + $Id('sgEstado').value + '&nmReferencia=' + $Id('nmReferencia').value + '&nuTelefonePre=' + $Id('nuTelefonePre').value + '&nuTelefone=' + $Id('nuTelefone').value + '&edEmail=' + $Id('edEmail').value + '&nuCpf=' + $Id('nuCpf').value + '&nuCnpj=' + $Id('nuCnpj').value + '&nuRG=' + $Id('nuRG').value, true);

		//Executada quando o navegador obtiver o código
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4){
				//Lê o texto
				var texto = new String(xmlhttp.responseText);

				//Desfaz o urlencode
				texto=texto.replace(/\+/g," ");
				texto=unescape(texto);


				//Retorna o resultado;
				if (texto.search('Erro ao tentar incluir/editar registro') != -1)
					alert(texto);
				else if (texto != ''){
					var saida = 'ASP *** Erro de validação:\n';
					//alert(texto);
					if (texto.search('cdServico')!=-1)
						saida += '\nPlano: ' + $Id('cdServico').title;
					if (texto.search('nmCliente')!=-1)
						saida += '\nNome: ' + $Id('nmCliente').title;
					if (texto.search('dmTipoPessoa')!=-1)
						saida += '\nPessoa F/J: ' + $Id('dmTipoPessoa').title;
					if (texto.search('nmRepresentante')!=-1)
						saida += '\nRepresentante: ' + $Id('nmRepresentante').title;
					if (texto.search('cdCidade')!=-1)
						saida += '\nCidade: ' + $Id('cdCidade').title;
					if (texto.search('cdBairro')!=-1)
						saida += '\nBairro: ' + $Id('cdBairro').title;
					if (texto.search('cdTema')!=-1)
						saida += '\nTipo de Logradouro: ' + $Id('cdTema').title;
					if (texto.search('nmLogradouro')!=-1)
						saida += '\nLogradouro: ' + $Id('nmLogradouro').title;
					if (texto.search('nuResidencia')!=-1)
						saida += '\nNúmero: ' + $Id('nuResidencia').title;
					if (texto.search('nuCEP')!=-1)
						saida += '\nCEP: ' + $Id('nuCEP').title;
					if (texto.search('sgEstado')!=-1)
						saida += '\nEstado: ' + $Id('sgEstado').title;
					if (texto.search('nmReferencia')!=-1)
						saida += '\nReferência: ' + $Id('nmReferencia').title;
					if (texto.search('nuTelefonePre')!=-1)
						saida += '\nPrefixo do Telefone: ' + $Id('nuTelefonePre').title;
					if (texto.search('nuTelefone')!=-1)
						saida += '\nTelefone: ' + $Id('nuTelefone').title;
					if (texto.search('edEmail')!=-1)
						saida += '\nE-mail: ' + $Id('edEmail').title;
					if (texto.search('nuCpf')!=-1)
						saida += '\nCPF: ' + $Id('nuCpf').title;
					if (texto.search('nuCnpj')!=-1)
						saida += '\nCNPJ: ' + $Id('nuCnpj').title;
					if (texto.search('nuRG')!=-1)
						saida += '\nRG: ' + $Id('nuRG').title;
					alert(saida);
				}
				else{
					alert("Solicitação realizada com sucesso!");
					window.location.href = 'Solicitacao.asp';
				}

				jsCarregando(0);
			}
		}
		xmlhttp.send(null)
	}
	else{
		var saida = 'Erro de validação:\n';

		if (!bcdServico){
			saida += '\nPlano: ' + $Id('cdServico').title;
			$Id('cdServico').focus();
		}
		else if (!bnmCliente){
			saida += '\nNome: ' + $Id('nmCliente').title;
			$Id('nmCliente').focus();
		}
		else if (!bdmTipoPessoa){
			saida += '\nPessoa F/J: ' + $Id('dmTipoPessoa').title;
			$Id('dmTipoPessoa').focus();
		}
		else if (!bnmRepresentante){
			saida += '\nRepresentante: ' + $Id('nmRepresentante').title;
			$Id('nmRepresentante').focus();
		}
		else if (!bcdCidade){
			saida += '\nCidade: ' + $Id('cdCidade').title;
			$Id('cdCidade').focus();
		}
		else if (!bcdBairro){
			saida += '\nBairro: ' + $Id('cdBairro').title;
			$Id('cdBairro').focus();
		}
		else if (!bcdTema){
			saida += '\nTipo de Logradouro: ' + $Id('cdTema').title;
			$Id('cdTema').focus();
		}
		else if (!bnmLogradouro){
			saida += '\nLogradouro: ' + $Id('nmLogradouro').title;
			$Id('nmLogradouro').focus();
		}
		else if (!bnuResidencia){
			saida += '\nNúmero: ' + $Id('nuResidencia').title;
			$Id('nuResidencia').focus();
		}
		else if (!bnuCEP){
			saida += '\nCEP: ' + $Id('nuCEP').title;
			$Id('nuCEP').focus();
		}
		else if (!bsgEstado){
			saida += '\nEstado: ' + $Id('sgEstado').title;
			$Id('sgEstado').focus();
		}
		else if (!bnmReferencia){
			saida += '\nReferência: ' + $Id('nmReferencia').title;
			$Id('nmReferencia').focus();
		}
		else if (!bnuTelefonePre){
			saida += '\nPrefixo do Telefone: ' + $Id('nuTelefonePre').title;
			$Id('nuTelefonePre').focus();
		}
		else if (!bnuTelefone){
			saida += '\nTelefone: ' + $Id('nuTelefone').title;
			$Id('nuTelefone').focus();
		}
		else if (!bedEmail){
			saida += '\nE-mail: ' + $Id('edEmail').title;
			$Id('edEmail').focus();
		}
		else if (!bnuCpf){
			saida += '\nCPF: ' + $Id('nuCpf').title;
			$Id('nuCpf').focus();
		}
		else if (!bnuCnpj){
			saida += '\nCNPJ: ' + $Id('nuCnpj').title;
			$Id('nuCnpj').focus();
		}
		else if (!bnuRG){
			saida += '\nRG: ' + $Id('nuRG').title;
			$Id('nuRG').focus();
		}
		alert(saida);
	}
}

function slctHospedagem(cd){

	if(xmlhttp && eval(cd)){
		//Abre a url
		xmlhttp.open('GET', 'bin/AjaxCadastroCliente.asp?op=2&cd=' + cd, true);

		//Executada quando o navegador obtiver o código
		xmlhttp.onreadystatechange=function() {

			if (xmlhttp.readyState==4){
				//Lê o texto
				var texto=xmlhttp.responseText

				//Desfaz o urlencode
				texto=texto.replace(/\+/g," ")
				texto=unescape(texto)

				if (texto.search(/(<script>)([^<]+)(<\/script>)/) != -1){
					var er = /(<script>)([^<]+)(<\/script>)/;
					var matriz = er.exec(texto);
					eval(matriz[2]);
					texto = texto.replace(/(<script>)([^<]+)(<\/script>)/, '')
				}
				//Exibe o texto no div conteúdo
				var liValores = document.getElementById("liValores")
				liValores.innerHTML=texto

				//setTimeout('jsOcultaRegistrarDominio()',500);
			}
		}
		xmlhttp.send(null)
	}else{
		document.getElementById("liValores").innerHTML='';
	}
}

function slctBairro(cd){

	if(xmlhttp){
		//Abre a url
		xmlhttp.open('GET', 'bin/AjaxCadastroCliente.asp?op=3&cd=' + cd, true);

		//Executada quando o navegador obtiver o código
		xmlhttp.onreadystatechange=function() {

			if (xmlhttp.readyState==4){
				//Lê o texto
				var texto=xmlhttp.responseText

				//Desfaz o urlencode
				texto=texto.replace(/\+/g," ")
				texto=unescape(texto)

				//Exibe o texto no div conteúdo
				var liBairro = document.getElementById("liBairro")
				liBairro.innerHTML=texto
			}
		}
		xmlhttp.send(null)
	}
}

function slctLogradouro(cd){

	if(xmlhttp){
		//Abre a url
		xmlhttp.open('GET', 'bin/AjaxCadastroCliente.asp?op=4&cd=' + cd, true);

		//Executada quando o navegador obtiver o código
		xmlhttp.onreadystatechange=function() {

			if (xmlhttp.readyState==4){
				//Lê o texto
				var texto=xmlhttp.responseText

				//Desfaz o urlencode
				texto=texto.replace(/\+/g," ")
				texto=unescape(texto)

				//Exibe o texto no div conteúdo
				var liEndereco = document.getElementById("liEndereco")
				liEndereco.innerHTML=texto
			}
		}
		xmlhttp.send(null)
	}
}

function jsAcessoDisponivel(cdTema, nmLogradouro){
//alert(cdTema);
//alert(nmLogradouro);
	if((xmlhttp) && (cdTema != '') && (nmLogradouro != '')){
		//Abre a url
		xmlhttp.open('GET', 'bin/AjaxCadastroCliente.asp?op=5&Tema=' + cdTema + '&Logradouro=' + nmLogradouro, true);

		//Executada quando o navegador obtiver o código
		xmlhttp.onreadystatechange=function() {

			if (xmlhttp.readyState==4){
				//Lê o texto
				var texto=xmlhttp.responseText

				//Desfaz o urlencode
				texto=texto.replace(/\+/g," ")
				texto=unescape(texto)

				//Exibe o texto no div conteúdo
				var idAcessoDisponivel = document.getElementById("idAcessoDisponivel")
				idAcessoDisponivel.innerHTML=texto
			}
		}
		xmlhttp.send(null)
	}else{
		document.getElementById("idAcessoDisponivel").innerHTML='';
	}
}
/*
function jsAcessoDisponivel(cd){

	if(xmlhttp && eval(cd)){
		//Abre a url
		xmlhttp.open('GET', 'bin/AjaxCadastroCliente.asp?op=5&cd=' + cd, true);

		//Executada quando o navegador obtiver o código
		xmlhttp.onreadystatechange=function() {

			if (xmlhttp.readyState==4){
				//Lê o texto
				var texto=xmlhttp.responseText

				//Desfaz o urlencode
				texto=texto.replace(/\+/g," ")
				texto=unescape(texto)

				//Exibe o texto no div conteúdo
				var idAcessoDisponivel = document.getElementById("idAcessoDisponivel")
				idAcessoDisponivel.innerHTML=texto
			}
		}
		xmlhttp.send(null)
	}else{
		document.getElementById("idAcessoDisponivel").innerHTML='';
	}
}
*/

function jsOcultar(){
	window.location = "Solicitacao.asp"
}

function jsAtivarSelect(){
	if ($Id('cdServico').value != ''){
		slctHospedagem($Id('cdServico').value);
	}
}

var value = "";
function jsRepresentante(value){

	if ((value == "F") || (value == "")){
		$Id('nmRepresentante').style.display = 'none';
		$Id('nmRepresentante').value = '';
		$Id('Cnpj').style.display = 'none';
		$Id('nuCnpj').style.display = 'none';
		$Id('Cpf').style.display = 'block';
		$Id('nuCpf').style.display = 'block';
	}else if (value == "J"){
		$Id('nmRepresentante').value = 'Representante(Pessoa Jurídica)*';
		$Id('nmRepresentante').style.display = 'block';
		$Id('Cnpj').style.display = 'block';
		$Id('nuCnpj').style.display = 'block';
		$Id('Cpf').style.display = 'none';
		$Id('nuCpf').style.display = 'none';
	}
}