
// Funções para Solicitação de Aluguel

function fixarRadioOptionSimples(acionador, alvo, par){

	if (document.getElementById(acionador).checked) {
		document.getElementById(alvo).checked = true;
		document.getElementById(par).checked = false;
	}

}

function fixarRadioOption(acionador, alvo, correspondente_alvo, par, correspondente_par){

	if (document.getElementById(acionador).checked) {
		document.getElementById(alvo).checked = document.getElementById(correspondente_alvo).checked;
		document.getElementById(par).checked = document.getElementById(correspondente_par).checked;
	}

}

function habilitarOutraDestinacao(seletor) {
	if (seletor.selectedIndex == seletor.length - 1) {
		document.getElementById('outras-destinacoes').disabled = '';
		document.getElementById('outras-destinacoes').readOnly = false;
		document.getElementById('outras-destinacoes').focus();
	} else {
		document.getElementById('outras-destinacoes').disabled = 'DISABLED';
		document.getElementById('outras-destinacoes').readOnly = true;
		document.getElementById('outras-destinacoes').value = '';
	}
}

var cnpj_proprietario = "";
var nome_comercial_proprietario = "";

var cpf_proprietario = "";
var rg_proprietario = "";
var rg_oe_proprietario = "";
var genero_proprietario = "1";
var estado_civil_proprietario = "";
var ocupacao_proprietario = "";
var naturalidade_proprietario = "";
var nacionalidade_proprietario = "";

var cnpj_titular = "";
var nome_comercial_titular = "";

var cpf_titular = "";
var rg_titular = "";
var rg_oe_titular = "";
var genero_titular = "1";
var estado_civil_titular = "";
var ocupacao_titular = "";
var naturalidade_titular = "";
var nacionalidade_titular = "";

function guardarValoresPJ() {

	//alert("guardar PJ");

	cnpj_proprietario = document.getElementById('cnpj').value;
	nome_comercial_proprietario = document.getElementById('nome-comercial').value;

}

function guardarValoresPF() {

	//alert("guardar PF");

	cpf_proprietario = document.getElementById('cpf').value;
	rg_proprietario = document.getElementById('rg').value;
	rg_oe_proprietario = document.getElementById('rg-oe').value;
	if (document.getElementById('genero-m').checked) {
		genero_proprietario = document.getElementById('genero-m').value;
	}
	if (document.getElementById('genero-f').checked) {
		genero_proprietario = document.getElementById('genero-f').value;
	}
	estado_civil_proprietario = document.getElementById('estado-civil').value;
	ocupacao_proprietario = document.getElementById('ocupacao').value;
	naturalidade_proprietario = document.getElementById('naturalidade').value;
	nacionalidade_proprietario = document.getElementById('nacionalidade').value;

}

function guardarValoresPJT() {

	//alert("guardar PJT");

	cnpj_titular = document.getElementById('cnpj-titular-conta').value;
	nome_comercial_titular = document.getElementById('nome-comercial-titular-conta').value;

}

function guardarValoresPFT() {

	//alert("guardar PFT");

	cpf_titular = document.getElementById('cpf-titular-conta').value;
	rg_titular = document.getElementById('rg-titular-conta').value;
	rg_oe_titular = document.getElementById('rg-oe-titular-conta').value;
	if (document.getElementById('genero-m-titular-conta').checked) {
		genero_titular = document.getElementById('genero-m-titular-conta').value;
	}
	if (document.getElementById('genero-f-titular-conta').checked) {
		genero_titular = document.getElementById('genero-f-titular-conta').value;
	}
	estado_civil_titular = document.getElementById('estado-civil-titular-conta').value;
	ocupacao_titular = document.getElementById('ocupacao-titular-conta').value;
	naturalidade_titular = document.getElementById('naturalidade-titular-conta').value;
	nacionalidade_titular = document.getElementById('nacionalidade-titular-conta').value;

}

function limparFormularioAluguel(){

}

function habilitarPessoaJuridica() {

	//alert("habilitar PJ");

	document.getElementById('cnpj').disabled = '';
	document.getElementById('cnpj').readOnly = false;
	document.getElementById('cnpj').value = cnpj_proprietario;
	document.getElementById('nome-comercial').disabled = '';
	document.getElementById('nome-comercial').readOnly = false;
	document.getElementById('nome-comercial').value = nome_comercial_proprietario;

	guardarValoresPJ();

	guardarValoresPF();

	document.getElementById('cpf').disabled = 'DISABLED';
	document.getElementById('cpf').readOnly = true;
	document.getElementById('cpf').value = '';
	document.getElementById('rg').disabled = 'DISABLED';
	document.getElementById('rg').readOnly = true;
	document.getElementById('rg').value = '';
	document.getElementById('rg-oe').disabled = 'DISABLED';
	document.getElementById('rg-oe').readOnly = true;
	document.getElementById('rg-oe').value = '';
	document.getElementById('genero-m').disabled = 'DISABLED';
	document.getElementById('genero-m').readOnly = true;
	document.getElementById('genero-m').checked = false;
	document.getElementById('genero-f').disabled = 'DISABLED';
	document.getElementById('genero-f').readOnly = true;
	document.getElementById('genero-f').checked = false;
	document.getElementById('estado-civil').disabled = 'DISABLED';
	document.getElementById('estado-civil').readOnly = true;
	document.getElementById('estado-civil').value = '';
	document.getElementById('ocupacao').disabled = 'DISABLED';
	document.getElementById('ocupacao').readOnly = true;
	document.getElementById('ocupacao').value = '';
	document.getElementById('naturalidade').disabled = 'DISABLED';
	document.getElementById('naturalidade').readOnly = true;
	document.getElementById('naturalidade').value = '';
	document.getElementById('nacionalidade').disabled = 'DISABLED';
	document.getElementById('nacionalidade').readOnly = true;
	document.getElementById('nacionalidade').value = '';

	if (document.getElementById('titular-conta-locador').checked) {

		//liberarCamposTitularConta();

		preencherDadosTitularLocador();

	}

	if (document.getElementById('possue-representante-nao').checked) {

		document.getElementById('possue-representante-sim').checked = true;
		document.getElementById('possue-representante-nao').checked = false;

		liberarRepresentanteLegal();

	}

	document.getElementById('cnpj').focus();

}

function habilitarPessoaFisica() {

	//alert("habilitar PF");

	guardarValoresPJ();

	document.getElementById('cnpj').disable = 'DISABLED';
	document.getElementById('cnpj').readOnly = true;
	document.getElementById('cnpj').value = '';
	document.getElementById('nome-comercial').disable = 'DISABLED';
	document.getElementById('nome-comercial').readOnly = true;
	document.getElementById('nome-comercial').value = '';

	document.getElementById('cpf').disabled = '';
	document.getElementById('cpf').readOnly = false;
	document.getElementById('cpf').value = cpf_proprietario;
	document.getElementById('rg').disabled = '';
	document.getElementById('rg').readOnly = false;
	document.getElementById('rg').value = rg_proprietario;
	document.getElementById('rg-oe').disabled = '';
	document.getElementById('rg-oe').readOnly = false;
	document.getElementById('rg-oe').value = rg_oe_proprietario;
	document.getElementById('genero-m').disabled = '';
	document.getElementById('genero-m').readOnly = false;
	document.getElementById('genero-f').disabled = '';
	document.getElementById('genero-f').readOnly = false;
	if (genero_proprietario == "1") {
		document.getElementById('genero-m').checked = " CHECKED";
	} else {
		document.getElementById('genero-f').checked = " CHECKED";
	}
	document.getElementById('estado-civil').disabled = '';
	document.getElementById('estado-civil').readOnly = false;
	document.getElementById('estado-civil').value = estado_civil_proprietario;
	document.getElementById('ocupacao').disabled = '';
	document.getElementById('ocupacao').readOnly = false;
	document.getElementById('ocupacao').value = ocupacao_proprietario;
	document.getElementById('naturalidade').disabled = '';
	document.getElementById('naturalidade').readOnly = false;
	document.getElementById('naturalidade').value = naturalidade_proprietario;
	document.getElementById('nacionalidade').disabled = '';
	document.getElementById('nacionalidade').readOnly = false;
	document.getElementById('nacionalidade').value = nacionalidade_proprietario;

	guardarValoresPF();

	if (document.getElementById('titular-conta-locador').checked) {

		//liberarCamposTitularConta();

		preencherDadosTitularLocador();

	}

	document.getElementById('cpf').focus();

}

function habilitarPessoaJuridicaTitular(focar, desabilitar, externo, especial) {

	/*
	if (document.getElementById('titular-conta-locador').checked) {

		fixarRadioOption('titular-conta-locador', 'tipo-documento-cnpj-titular-conta', 'tipo-documento-cnpj', 'tipo-documento-cpf-titular-conta', 'tipo-documento-cpf');

		if (!desabilitar) {
			desabilitar = true;
		} else {
			desabilitar = false;
		}
	}
	*/

	if (especial)
		if (!desabilitar) {
			desabilitar = true;
		} else {
			desabilitar = false;
		}

	if (desabilitar) {

		//alert("habilitar PJT");

		if (document.getElementById('titular-conta-recebedor').checked || externo) {

			document.getElementById('cnpj-titular-conta').disabled = '';
			document.getElementById('cnpj-titular-conta').readOnly = false;
			document.getElementById('cnpj-titular-conta').value = cnpj_titular;
			document.getElementById('nome-comercial-titular-conta').disabled = '';
			document.getElementById('nome-comercial-titular-conta').readOnly = false;
			document.getElementById('nome-comercial-titular-conta').value = nome_comercial_titular;

			guardarValoresPJT();

			guardarValoresPFT();

			document.getElementById('cpf-titular-conta').disabled = 'DISABLED';
			document.getElementById('cpf-titular-conta').readOnly = true;
			document.getElementById('cpf-titular-conta').value = '';
			document.getElementById('rg-titular-conta').disabled = 'DISABLED';
			document.getElementById('rg-titular-conta').readOnly = true;
			document.getElementById('rg-titular-conta').value = '';
			document.getElementById('rg-oe-titular-conta').disabled = 'DISABLED';
			document.getElementById('rg-oe-titular-conta').readOnly = true;
			document.getElementById('rg-oe-titular-conta').value = '';
			document.getElementById('genero-m-titular-conta').disabled = 'DISABLED';
			document.getElementById('genero-m-titular-conta').readOnly = true;
			document.getElementById('genero-m-titular-conta').checked = false;
			document.getElementById('genero-f-titular-conta').disabled = 'DISABLED';
			document.getElementById('genero-f-titular-conta').readOnly = true;
			document.getElementById('genero-f-titular-conta').checked = false;
			document.getElementById('estado-civil-titular-conta').disabled = 'DISABLED';
			document.getElementById('estado-civil-titular-conta').readOnly = true;
			document.getElementById('estado-civil-titular-conta').value = '';
			document.getElementById('ocupacao-titular-conta').disabled = 'DISABLED';
			document.getElementById('ocupacao-titular-conta').readOnly = true;
			document.getElementById('ocupacao-titular-conta').value = '';
			document.getElementById('naturalidade-titular-conta').disabled = 'DISABLED';
			document.getElementById('naturalidade-titular-conta').readOnly = true;
			document.getElementById('naturalidade-titular-conta').value = '';
			document.getElementById('nacionalidade-titular-conta').disabled = 'DISABLED';
			document.getElementById('nacionalidade-titular-conta').readOnly = true;
			document.getElementById('nacionalidade-titular-conta').value = '';

			if (focar)
				document.getElementById('cnpj-titular-conta').focus();

		} else {

			document.getElementById('tipo-documento-cnpj-titular-conta').checked = document.getElementById('tipo-documento-cnpj').checked;
			document.getElementById('tipo-documento-cpf-titular-conta').checked = document.getElementById('tipo-documento-cpf').checked;

			alert("Os dados não podem ser alterados pois o proprietário está definido como titular da conta.");

		}

	}

}

function habilitarPessoaFisicaTitular(focar, desabilitar, externo, especial) {

	/*
	if (document.getElementById('titular-conta-locador').checked) {

		fixarRadioOption('titular-conta-locador', 'tipo-documento-cpf-titular-conta', 'tipo-documento-cpf', 'tipo-documento-cnpj-titular-conta', 'tipo-documento-cnpj');

		if (!desabilitar) {
			desabilitar = true;
		} else {
			desabilitar = false;
		}
	}
	*/

	if (especial)
		if (!desabilitar) {
			desabilitar = true;
		} else {
			desabilitar = false;
		}

	if (desabilitar) {

		//alert("habilitar PFT");

		if (document.getElementById('titular-conta-recebedor').checked || externo) {

			guardarValoresPJT();

			document.getElementById('cnpj-titular-conta').disabled = 'DISABLED';
			document.getElementById('cnpj-titular-conta').readOnly = true;
			document.getElementById('cnpj-titular-conta').value = '';
			document.getElementById('nome-comercial-titular-conta').disabled = 'DISABLED';
			document.getElementById('nome-comercial-titular-conta').readOnly = true;
			document.getElementById('nome-comercial-titular-conta').value = '';

			document.getElementById('cpf-titular-conta').disabled = '';
			document.getElementById('cpf-titular-conta').readOnly = false;
			document.getElementById('cpf-titular-conta').value = cpf_titular;
			document.getElementById('rg-titular-conta').disabled = '';
			document.getElementById('rg-titular-conta').readOnly = false;
			document.getElementById('rg-titular-conta').value = rg_titular;
			document.getElementById('rg-oe-titular-conta').disabled = '';
			document.getElementById('rg-oe-titular-conta').readOnly = false;
			document.getElementById('rg-oe-titular-conta').value = rg_oe_titular;
			document.getElementById('genero-m-titular-conta').disabled = '';
			document.getElementById('genero-m-titular-conta').readOnly = false;
			document.getElementById('genero-f-titular-conta').disabled = '';
			document.getElementById('genero-f-titular-conta').readOnly = false;
			if (genero_titular == "1") {
				document.getElementById('genero-m-titular-conta').checked = " CHECKED";
			} else {
				document.getElementById('genero-f-titular-conta').checked = " CHECKED";
			}
			document.getElementById('estado-civil-titular-conta').disabled = '';
			document.getElementById('estado-civil-titular-conta').readOnly = false;
			document.getElementById('estado-civil-titular-conta').value = estado_civil_titular;
			document.getElementById('ocupacao-titular-conta').disabled = '';
			document.getElementById('ocupacao-titular-conta').readOnly = false;
			document.getElementById('ocupacao-titular-conta').value = ocupacao_titular;
			document.getElementById('naturalidade-titular-conta').disabled = '';
			document.getElementById('naturalidade-titular-conta').readOnly = false;
			document.getElementById('naturalidade-titular-conta').value = naturalidade_titular;
			document.getElementById('nacionalidade-titular-conta').disabled = '';
			document.getElementById('nacionalidade-titular-conta').readOnly = false;
			document.getElementById('nacionalidade-titular-conta').value = nacionalidade_titular;

			guardarValoresPFT();

			if (focar)
				document.getElementById('cpf-titular-conta').focus();

		} else {

			document.getElementById('tipo-documento-cnpj-titular-conta').checked = document.getElementById('tipo-documento-cnpj').checked;
			document.getElementById('tipo-documento-cpf-titular-conta').checked = document.getElementById('tipo-documento-cpf').checked;

			alert("Os dados não podem ser alterados pois o proprietário está definido como titular da conta.");

		}

	}

}

function preencherDadosTitularLocador() {

	if (document.getElementById('tipo-documento-cnpj').checked) {

		//alert("preencher pjt");

		if (document.getElementById('cnpj').value != "" &&
			document.getElementById('nome-comercial').value != "") {

			document.getElementById('tipo-documento-cnpj-titular-conta').checked = true;
			document.getElementById('tipo-documento-cpf-titular-conta').checked = false;

			guardarValoresPJ();

			document.getElementById('cnpj-titular-conta').disabled = '';
			document.getElementById('cnpj-titular-conta').readOnly = true;
			document.getElementById('cnpj-titular-conta').value = cnpj_proprietario;
			document.getElementById('nome-comercial-titular-conta').disabled = '';
			document.getElementById('nome-comercial-titular-conta').readOnly = true;
			document.getElementById('nome-comercial-titular-conta').value = nome_comercial_proprietario;

			guardarValoresPJT();

			guardarValoresPFT();

			document.getElementById('cpf-titular-conta').disabled = 'DISABLED';
			document.getElementById('cpf-titular-conta').readOnly = true;
			document.getElementById('cpf-titular-conta').value = '';
			document.getElementById('rg-titular-conta').disabled = 'DISABLED';
			document.getElementById('rg-titular-conta').readOnly = true;
			document.getElementById('rg-titular-conta').value = '';
			document.getElementById('rg-oe-titular-conta').disabled = 'DISABLED';
			document.getElementById('rg-oe-titular-conta').readOnly = true;
			document.getElementById('rg-oe-titular-conta').value = '';
			document.getElementById('genero-m-titular-conta').disabled = 'DISABLED';
			document.getElementById('genero-m-titular-conta').readOnly = true;
			document.getElementById('genero-m-titular-conta').checked = false;
			document.getElementById('genero-f-titular-conta').disabled = 'DISABLED';
			document.getElementById('genero-f-titular-conta').readOnly = true;
			document.getElementById('genero-f-titular-conta').checked = false;
			document.getElementById('estado-civil-titular-conta').disabled = 'DISABLED';
			document.getElementById('estado-civil-titular-conta').readOnly = true;
			document.getElementById('estado-civil-titular-conta').value = '';
			document.getElementById('ocupacao-titular-conta').disabled = 'DISABLED';
			document.getElementById('ocupacao-titular-conta').readOnly = true;
			document.getElementById('ocupacao-titular-conta').value = '';
			document.getElementById('naturalidade-titular-conta').disabled = 'DISABLED';
			document.getElementById('naturalidade-titular-conta').readOnly = true;
			document.getElementById('naturalidade-titular-conta').value = '';
			document.getElementById('nacionalidade-titular-conta').disabled = 'DISABLED';
			document.getElementById('nacionalidade-titular-conta').readOnly = true;
			document.getElementById('nacionalidade-titular-conta').value = '';

			document.getElementById('nome-titular-conta').value = document.getElementById('nome-outra-parte').value;
			document.getElementById('endereco-titular-conta').value = document.getElementById('endereco-outra-parte').value;
			document.getElementById('telefones-titular-conta').value = document.getElementById('telefones').value;
			document.getElementById('emails-titular-conta').value = document.getElementById('emails').value;

		} else {

			alert("Preencha todos os dados do proprietário antes.");

			liberarCamposTitularConta();

		}

	}

	if (document.getElementById('tipo-documento-cpf').checked) {

		//alert("preencher pft");

		if (document.getElementById('cpf').value != "" &&
			document.getElementById('rg').value != "" &&
			document.getElementById('rg-oe').value != "" &&
			document.getElementById('estado-civil').value != "" &&
			document.getElementById('ocupacao').value != "" &&
			document.getElementById('naturalidade').value != "" &&
			document.getElementById('nacionalidade').value != "") {

			document.getElementById('tipo-documento-cnpj-titular-conta').checked = false;
			document.getElementById('tipo-documento-cpf-titular-conta').checked = true;

			guardarValoresPJT();

			document.getElementById('cnpj-titular-conta').disabled = 'DISABLED';
			document.getElementById('cnpj-titular-conta').readOnly = true;
			document.getElementById('cnpj-titular-conta').value = '';
			document.getElementById('nome-comercial-titular-conta').disabled = 'DISABLED';
			document.getElementById('nome-comercial-titular-conta').readOnly = true;
			document.getElementById('nome-comercial-titular-conta').value = '';

			guardarValoresPF();

			document.getElementById('cpf-titular-conta').disabled = '';
			document.getElementById('cpf-titular-conta').readOnly = true;
			document.getElementById('cpf-titular-conta').value = cpf_proprietario;
			document.getElementById('rg-titular-conta').disabled = '';
			document.getElementById('rg-titular-conta').readOnly = true;
			document.getElementById('rg-titular-conta').value = rg_proprietario;
			document.getElementById('rg-oe-titular-conta').disabled = '';
			document.getElementById('rg-oe-titular-conta').readOnly = true;
			document.getElementById('rg-oe-titular-conta').value = rg_oe_proprietario;
			document.getElementById('genero-m-titular-conta').disabled = '';
			document.getElementById('genero-m-titular-conta').readOnly = true;
			document.getElementById('genero-f-titular-conta').disabled = '';
			document.getElementById('genero-f-titular-conta').readOnly = true;
			if (genero_proprietario == "1") {
				document.getElementById('genero-m-titular-conta').checked = " CHECKED";
			} else {
				document.getElementById('genero-f-titular-conta').checked = " CHECKED";
			}
			document.getElementById('estado-civil-titular-conta').disabled = '';
			document.getElementById('estado-civil-titular-conta').readOnly = true;
			document.getElementById('estado-civil-titular-conta').value = estado_civil_proprietario;
			document.getElementById('ocupacao-titular-conta').disabled = '';
			document.getElementById('ocupacao-titular-conta').readOnly = true;
			document.getElementById('ocupacao-titular-conta').value = ocupacao_proprietario;
			document.getElementById('naturalidade-titular-conta').disabled = '';
			document.getElementById('naturalidade-titular-conta').readOnly = true;
			document.getElementById('naturalidade-titular-conta').value = naturalidade_proprietario;
			document.getElementById('nacionalidade-titular-conta').disabled = '';
			document.getElementById('nacionalidade-titular-conta').readOnly = true;
			document.getElementById('nacionalidade-titular-conta').value = nacionalidade_proprietario;

			guardarValoresPFT();

			document.getElementById('nome-titular-conta').value = document.getElementById('nome-outra-parte').value;
			document.getElementById('endereco-titular-conta').value = document.getElementById('endereco-outra-parte').value;
			document.getElementById('telefones-titular-conta').value = document.getElementById('telefones').value;
			document.getElementById('emails-titular-conta').value = document.getElementById('emails').value;

		} else {

			alert("Preencha todos os dados do proprietário antes.");

			liberarCamposTitularConta();

		}

	}

}

function liberarCamposTitularConta() {

	document.getElementById('titular-conta-locador').checked = false;
	document.getElementById('titular-conta-recebedor').checked = true;

	if (document.getElementById('tipo-documento-cnpj-titular-conta').checked) {

		//alert("liberar PJT");

		document.getElementById('cnpj-titular-conta').disabled = '';
		document.getElementById('cnpj-titular-conta').readOnly = false;
		document.getElementById('cnpj-titular-conta').value = cnpj_titular;
		document.getElementById('nome-comercial-titular-conta').disabled = '';
		document.getElementById('nome-comercial-titular-conta').readOnly = false;
		document.getElementById('nome-comercial-titular-conta').value = nome_comercial_titular;

		guardarValoresPJT();

		guardarValoresPFT();

		document.getElementById('cpf-titular-conta').disabled = 'DISABLED';
		document.getElementById('cpf-titular-conta').readOnly = true;
		document.getElementById('cpf-titular-conta').value = '';
		document.getElementById('rg-titular-conta').disabled = 'DISABLED';
		document.getElementById('rg-titular-conta').readOnly = true;
		document.getElementById('rg-titular-conta').value = '';
		document.getElementById('rg-oe-titular-conta').disabled = 'DISABLED';
		document.getElementById('rg-oe-titular-conta').readOnly = true;
		document.getElementById('rg-oe-titular-conta').value = '';
		document.getElementById('genero-m-titular-conta').disabled = 'DISABLED';
		document.getElementById('genero-m-titular-conta').readOnly = true;
		document.getElementById('genero-m-titular-conta').checked = false;
		document.getElementById('genero-f-titular-conta').disabled = 'DISABLED';
		document.getElementById('genero-f-titular-conta').readOnly = true;
		document.getElementById('genero-f-titular-conta').checked = false;
		document.getElementById('estado-civil-titular-conta').disabled = 'DISABLED';
		document.getElementById('estado-civil-titular-conta').readOnly = true;
		document.getElementById('estado-civil-titular-conta').value = '';
		document.getElementById('ocupacao-titular-conta').disabled = 'DISABLED';
		document.getElementById('ocupacao-titular-conta').readOnly = true;
		document.getElementById('ocupacao-titular-conta').value = '';
		document.getElementById('naturalidade-titular-conta').disabled = 'DISABLED';
		document.getElementById('naturalidade-titular-conta').readOnly = true;
		document.getElementById('naturalidade-titular-conta').value = '';
		document.getElementById('nacionalidade-titular-conta').disabled = 'DISABLED';
		document.getElementById('nacionalidade-titular-conta').readOnly = true;
		document.getElementById('nacionalidade-titular-conta').value = '';

	}

	if (document.getElementById('tipo-documento-cpf-titular-conta').checked) {

		//alert("liberar PFT");

		guardarValoresPJT();

		document.getElementById('cnpj-titular-conta').disabled = 'DISABLED';
		document.getElementById('cnpj-titular-conta').readOnly = true;
		document.getElementById('cnpj-titular-conta').value = '';
		document.getElementById('nome-comercial-titular-conta').disabled = 'DISABLED';
		document.getElementById('nome-comercial-titular-conta').readOnly = true;
		document.getElementById('nome-comercial-titular-conta').value = '';

		document.getElementById('cpf-titular-conta').disabled = '';
		document.getElementById('cpf-titular-conta').readOnly = false;
		document.getElementById('cpf-titular-conta').value = cpf_titular;
		document.getElementById('rg-titular-conta').disabled = '';
		document.getElementById('rg-titular-conta').readOnly = false;
		document.getElementById('rg-titular-conta').value = rg_titular;
		document.getElementById('rg-oe-titular-conta').disabled = '';
		document.getElementById('rg-oe-titular-conta').readOnly = false;
		document.getElementById('rg-oe-titular-conta').value = rg_oe_titular;
		document.getElementById('genero-m-titular-conta').disabled = '';
		document.getElementById('genero-m-titular-conta').readOnly = false;
		document.getElementById('genero-f-titular-conta').disabled = '';
		document.getElementById('genero-f-titular-conta').readOnly = false;
		if (genero_titular == "1") {
			document.getElementById('genero-m-titular-conta').checked = " CHECKED";
		} else {
			document.getElementById('genero-f-titular-conta').checked = " CHECKED";
		}
		document.getElementById('estado-civil-titular-conta').disabled = '';
		document.getElementById('estado-civil-titular-conta').readOnly = false;
		document.getElementById('estado-civil-titular-conta').value = estado_civil_titular;
		document.getElementById('ocupacao-titular-conta').disabled = '';
		document.getElementById('ocupacao-titular-conta').readOnly = false;
		document.getElementById('ocupacao-titular-conta').value = ocupacao_titular;
		document.getElementById('naturalidade-titular-conta').disabled = '';
		document.getElementById('naturalidade-titular-conta').readOnly = false;
		document.getElementById('naturalidade-titular-conta').value = naturalidade_titular;
		document.getElementById('nacionalidade-titular-conta').disabled = '';
		document.getElementById('nacionalidade-titular-conta').readOnly = false;
		document.getElementById('nacionalidade-titular-conta').value = nacionalidade_titular;

		guardarValoresPFT();

	}

}

function liberarRepresentanteLegal() {

	document.getElementById('cpf-representante').readOnly = false;
	document.getElementById('rg-representante').readOnly = false;
	document.getElementById('rg-oe-representante').readOnly = false;
	document.getElementById('estado-civil-representante').readOnly = false;
	document.getElementById('ocupacao-representante').readOnly = false;
	document.getElementById('naturalidade-representante').readOnly = false;
	document.getElementById('nacionalidade-representante').readOnly = false;
	document.getElementById('nome-representante').readOnly = false;
	document.getElementById('endereco-representante').readOnly = false;
	document.getElementById('telefones-representante').readOnly = false;
	document.getElementById('emails-representante').readOnly = false;

	document.getElementById('cpf-representante').disabled = '';
	document.getElementById('rg-representante').disabled = '';
	document.getElementById('rg-oe-representante').disabled = '';
	document.getElementById('genero-m-representante').disabled = '';
	document.getElementById('genero-f-representante').disabled = '';
	document.getElementById('estado-civil-representante').disabled = '';
	document.getElementById('ocupacao-representante').disabled = '';
	document.getElementById('naturalidade-representante').disabled = '';
	document.getElementById('nacionalidade-representante').disabled = '';
	document.getElementById('nome-representante').disabled = '';
	document.getElementById('endereco-representante').disabled = '';
	document.getElementById('telefones-representante').disabled = '';
	document.getElementById('emails-representante').disabled = '';

}

function bloquearRepresentanteLegal() {

	if (document.getElementById('tipo-documento-cpf').checked) {

		document.getElementById('cpf-representante').value = "";
		document.getElementById('rg-representante').value = "";
		document.getElementById('rg-oe-representante').value = "";
		document.getElementById('estado-civil-representante').value = "";
		document.getElementById('ocupacao-representante').value = "";
		document.getElementById('naturalidade-representante').value = "";
		document.getElementById('nacionalidade-representante').value = "";
		document.getElementById('nome-representante').value = "";
		document.getElementById('endereco-representante').value = "";
		document.getElementById('telefones-representante').value = "";
		document.getElementById('emails-representante').value = "";

		document.getElementById('cpf-representante').readOnly = true;
		document.getElementById('rg-representante').readOnly = true;
		document.getElementById('rg-oe-representante').readOnly = true;
		document.getElementById('genero-m-representante').checked = false;
		document.getElementById('genero-f-representante').checked = false;
		document.getElementById('estado-civil-representante').readOnly = true;
		document.getElementById('ocupacao-representante').readOnly = true;
		document.getElementById('naturalidade-representante').readOnly = true;
		document.getElementById('nacionalidade-representante').readOnly = true;
		document.getElementById('nome-representante').readOnly = true;
		document.getElementById('endereco-representante').readOnly = true;
		document.getElementById('telefones-representante').readOnly = true;
		document.getElementById('emails-representante').readOnly = true;

		document.getElementById('cpf-representante').disabled = 'DISABLED';
		document.getElementById('rg-representante').disabled = 'DISABLED';
		document.getElementById('rg-oe-representante').disabled = 'DISABLED';
		document.getElementById('genero-m-representante').disabled = 'DISABLED';
		document.getElementById('genero-f-representante').disabled = 'DISABLED';
		document.getElementById('estado-civil-representante').disabled = 'DISABLED';
		document.getElementById('ocupacao-representante').disabled = 'DISABLED';
		document.getElementById('naturalidade-representante').disabled = 'DISABLED';
		document.getElementById('nacionalidade-representante').disabled = 'DISABLED';
		document.getElementById('nome-representante').disabled = 'DISABLED';
		document.getElementById('endereco-representante').disabled = 'DISABLED';
		document.getElementById('telefones-representante').disabled = 'DISABLED';
		document.getElementById('emails-representante').disabled = 'DISABLED';

	}

	if (document.getElementById('tipo-documento-cnpj').checked) {

		document.getElementById('possue-representante-sim').checked = true;
		document.getElementById('possue-representante-nao').checked = false;

		liberarRepresentanteLegal();

	}

}

function compararValoresAluguel(objeto, campo_1, campo_2) {

	valor_pgto = document.getElementById(campo_1).value;
	//alert("valor_pgto 1: " + valor_pgto);

	valor_total_pgto = document.getElementById(campo_2).value;
	//alert("valor_total_pgto 1: " + valor_total_pgto);

	valor_pgto = remove(valor_pgto, ".", "");
	//alert("valor_pgto 2: " + valor_pgto);
	valor_pgto = remove(valor_pgto, ",", ".");
	//alert("valor_pgto 3: " + valor_pgto);

	valor_total_pgto = remove(valor_total_pgto, ".", "");
	//alert("valor_total_pgto 2: " + valor_total_pgto);
	valor_total_pgto = remove(valor_total_pgto, ",", ".");
	//alert("valor_total_pgto 3: " + valor_total_pgto);

	valor_pgto = parseFloat(valor_pgto);
	//alert("valor_pgto 4: " + valor_pgto);

	valor_total_pgto = parseFloat(valor_total_pgto);
	//alert("valor_total_pgto 4: " + valor_total_pgto);

	if (valor_total_pgto > 0)
		if (valor_total_pgto < valor_pgto) {
			alert("O Valor Total está menor que o Valor do Pagamento Mensal!");
			objeto.value = "0,00";
			focarCampo(objeto);
		}

}

function validarSolicitarAluguel(nameform) {

	//Se a Unidade for nula
	if(document.getElementById('und-solicitante').selectedIndex == 0) {
		alert("Por favor selecione a Unidade!");
		return false;
	}

	//Se o Solicitante for nulo
	if (document.getElementById('solicitante').value == "") {
		alert("Por favor selecione o Solicitante!");
		return false;
	}

	/*
	//Se a FR for nula
	if(document.getElementById('fonte').selectedIndex == 0) {
		alert("Por favor selecione a Fonte de Recursos!");
		return false;
	}

	//Se a Ação for nula
	if(document.getElementById('acao').selectedIndex == 0) {
		alert("Por favor selecione a Ação!");
		return false;
	}
	*/

	//Se a Destinação do Imóvel for nula
	if (document.getElementById('destinacao-imovel').value == "") {
		alert("Por favor selecione a Destinação do Imóvel do Contrato!");
		return false;
	}

	//Se a Destinação do Imóvel for nula
	if (document.getElementById('destinacao-imovel').value == "OUTRAS") {
		if (document.getElementById('outras-destinacoes').value == "") {
			alert("Por favor digite a Destinação do Imóvel do Contrato!");
			return false;
		}
	}

	//Se o Endereço do Imóvel for nulo
	if(document.getElementById('endereco-imovel').value == "") {
		alert("Por favor digite o Endereço do Imóvel do Contrato!");
		return false;
	}

	//Se a Regional for nula
	if(document.getElementById('regional').selectedIndex == 0) {
		alert("Por favor selecione a Regional do Município onde está o Imóvel!");
		return false;
	}

	//Se o Município for nulo
	if(document.getElementById('municipio').value == "") {
		alert("Por favor selecione o Município onde está o Imóvel!");
		return false;
	}

	//Se a Descrição do Imóvel for nula
	if(document.getElementById('descricao-imovel').value == "") {
		alert("Por favor digite a Descrição do Imóvel do Contrato!");
		return false;
	}

	/*
	//Se a Melhoria do Imóvel for nula
	if(document.getElementById('melhorias-imovel').value == "") {
		alert("Por favor digite as Melhorias a serem feitas no Imóvel do Contrato!");
		return false;
	}
	*/

	if(document.getElementById('prazo-contrato').value == "") {
		alert("Por favor digite o Prazo do Contrato!");
		return false;
	}
	if(document.getElementById('und-tempo-prazo').selectedIndex == 0) {
		alert("Por favor selecione a unidade de tempo do Prazo do Contrato!");
		return false;
	}

	if (document.getElementById('data-inicio').value == "00/00/0000") {
		alert("Por favor selecione a data de início do contrato!");
		return false;
	}

	if (document.getElementById('data-fim').value == "00/00/0000") {
		alert("Por favor selecione a data de encerramento do contrato!");
		return false;
	}

	/*
	if(document.getElementById('dia-pgto').value == "") {
		alert("Por favor digite o dia do Pagamento Mensal!");
		return false;
	}

	dia_pgto = document.getElementById('dia-pgto').value;
	dia_pgto = parseInt(dia_pgto);

	if(dia_pgto < 1 || dia_pgto > 28) {
		alert("Por favor digite apenas valores entre 1 e 28 para o dia do Pagamento Mensal!");
		
	return false;
	}
	*/

	valor_pgto = document.getElementById('valor-pgto').value;
	valor_pgto = remove(valor_pgto,".", "");
	valor_pgto = remove(valor_pgto,",", ".");
	valor_pgto = parseFloat(valor_pgto);

	if (valor_pgto <= 0) {
		alert("Por favor digite o Valor do Pagamento Mensal!");
		return false;
	}

	valor_total_pgto = document.getElementById('valor-total-pgto').value;
	valor_total_pgto = remove(valor_total_pgto,".", "");
	valor_total_pgto = remove(valor_total_pgto,",", ".");
	valor_total_pgto = parseFloat(valor_total_pgto);

	if (valor_total_pgto <= 0) {
		alert("Por favor digite o Valor Total do Pagamento!");
		return false;
	}

	if (valor_pgto > valor_total_pgto) {
		alert("O Valor Total do Pagamento está menor que o Valor do Pagamento Mensal!");
		return false;
	}

	//Se o CPF ou CNPJ for nulo
	if (document.getElementById('tipo-documento-cpf').checked) {
		if(document.getElementById('cpf').value == "") {
			alert("Por favor digite o CPF da outra parte no Contrato!");
			return false;
		}
		//Se o RG for nulo
		if(document.getElementById('rg').value == "") {
			alert("Por favor digite o RG da outra parte no Contrato!");
			return false;
		}
		if(document.getElementById('rg-oe').value == "") {
			alert("Por favor digite o Orgão Emissor do RG da outra parte no Contrato!");
			return false;
		}

		if (document.getElementById('genero-m') != null &&
			document.getElementById('genero-f') != null)
			if (!document.getElementById('genero-m').checked &&
				!document.getElementById('genero-f').checked) {
				alert("Por favor selecione o sexo da outra parte no Contrato!");
				return false;
			}

		if(document.getElementById('estado-civil').value == "") {
			alert("Por favor digite o Estado Civil da outra parte no Contrato!");
			return false;
		}
		if(document.getElementById('ocupacao').value == "") {
			alert("Por favor digite a Ocupação da outra parte no Contrato!");
			return false;
		}
		if(document.getElementById('naturalidade').value == "") {
			alert("Por favor digite a Naturalidade da outra parte no Contrato!");
			return false;
		}
		if(document.getElementById('nacionalidade').value == "") {
			alert("Por favor digite a Nacionalidade da outra parte no Contrato!");
			return false;
		}
	} else {
		if(document.getElementById('cnpj').value == "") {
			alert("Por favor digite o CNPJ da outra parte no Contrato!");
			return false;
		}

		if(document.getElementById('nome-comercial').value == "") {
			alert("Por favor digite o Nome Comercial (Fantasia) da outra parte no Contrato!");
			return false;
		}

	}

	//Se o Nome da outra parte for nulo
	if(document.getElementById('nome-outra-parte').value == "") {
		alert("Por favor digite o nome da outra parte no Contrato!");
		return false;
	}

	//Se o Endereço da outra parte for nulo
	if(document.getElementById('endereco-outra-parte').value == "") {
		alert("Por favor digite o Endereço da outra parte no Contrato!");
		return false;
	}



	if (document.getElementById('banco').value == "") {
		alert("Por favor digite o nome do Banco!");
		return false;
	}

	if (document.getElementById('agencia').value == "") {
		alert("Por favor digite o Código da Agência!");
		return false;
	}

	/*
	if (document.getElementById('agencia-digito').value == "") {
		alert("Por favor digite o dígito do Código da Agência!");
		return false;
	}
	*/

	if (document.getElementById('cc').value == "") {
		alert("Por favor digite o Código da Conta Corrente!");
		return false;
	}

	if (document.getElementById('cc-digito').value == "") {
		alert("Por favor digite o dígito do Código da Conta Corrente!");
		return false;
	}

	if (document.getElementById('titular-conta-recebedor').checked) {

		if (document.getElementById('tipo-documento-cpf-titular-conta').checked) {
			if (document.getElementById('cpf-titular-conta').value == "") {
				alert("Por favor digite o CPF do Titular da Conta!");
				return false;
			}

			if (document.getElementById('rg-titular-conta').value == "") {
				alert("Por favor digite o RG do Titular da Conta!");
				return false;
			}

			if (document.getElementById('rg-oe-titular-conta').value == "") {
				alert("Por favor digite o Orgão Emissor do RG do Titular da Conta!");
				return false;
			}

			if (document.getElementById('genero-m-titular-conta') != null &&
				document.getElementById('genero-f-titular-conta') != null)
				if (!document.getElementById('genero-m-titular-conta').checked &&
					!document.getElementById('genero-f-titular-conta').checked) {
					alert("Por favor selecione o sexo do Titular da Conta!");
					return false;
				}

			if(document.getElementById('estado-civil-titular-conta').value == "") {
				alert("Por favor digite o Estado Civil do Titular da Conta!");
				return false;
			}
			if(document.getElementById('ocupacao-titular-conta').value == "") {
				alert("Por favor digite a Ocupação do Titular da Conta!");
				return false;
			}
			if(document.getElementById('naturalidade-titular-conta').value == "") {
				alert("Por favor digite a Naturalidade do Titular da Conta!");
				return false;
			}
			if(document.getElementById('nacionalidade-titular-conta').value == "") {
				alert("Por favor digite a Nacionalidade do Titular da Conta!");
				return false;
			}

		} else {
			if(document.getElementById('cnpj-titular-conta').value == "") {
				alert("Por favor digite o CNPJ do Titular da Conta!");
				return false;
			}

			if(document.getElementById('nome-comercial-titular-conta').value == "") {
				alert("Por favor digite o Nome Comercial (Fantasia) do Titular da Conta!");
				return false;
			}

		}

		if (document.getElementById('nome-titular-conta').value == "") {
			alert("Por favor digite o nome do Titular da Conta!");
			return false;
		}

		if (document.getElementById('endereco-titular-conta').value == "") {
			alert("Por favor digite o endereço residencial do Titular da Conta!");
			return false;
		}
	}



	if (document.getElementById('possue-representante-sim').checked ||
		document.getElementById('tipo-documento-cnpj').checked) {

		if (document.getElementById('cpf-representante').value == "") {
			alert("Por favor digite o CPF do Representante!");
			return false;
		}

		if (document.getElementById('rg-representante').value == "") {
			alert("Por favor digite o RG do Representante!");
			return false;
		}

		if (document.getElementById('rg-oe-representante').value == "") {
			alert("Por favor digite o Orgão Emissor do RG do Representante!");
			return false;
		}

		if (document.getElementById('genero-m-representante') != null &&
			document.getElementById('genero-f-representante') != null)
			if (!document.getElementById('genero-m-representante').checked &&
				!document.getElementById('genero-f-representante').checked) {
				alert("Por favor selecione o sexo do Representante!");
				return false;
			}

		if(document.getElementById('estado-civil-representante').value == "") {
			alert("Por favor digite o Estado Civil do Representante!");
			return false;
		}
		if(document.getElementById('ocupacao-representante').value == "") {
			alert("Por favor digite a Ocupação do Representante!");
			return false;
		}
		if(document.getElementById('naturalidade-representante').value == "") {
			alert("Por favor digite a Naturalidade do Representante!");
			return false;
		}
		if(document.getElementById('nacionalidade-representante').value == "") {
			alert("Por favor digite a Nacionalidade do Representante!");
			return false;
		}

		if (document.getElementById('nome-representante').value == "") {
			alert("Por favor digite o nome do Representante!");
			return false;
		}

		if (document.getElementById('endereco-representante').value == "") {
			alert("Por favor digite o endereço residencial do Representante!");
			return false;
		}

	}

	resposta = confirm("Você tem certeza que deseja submeter esta solicitação?");

	if (resposta) {
		return true;
	} else {
		return false;
	}

}

var permitir_validar_avaliar_aluguel = true;

function validarAvaliarAluguel() {

	if (permitir_validar_avaliar_aluguel) {

		//alert("Entrou!");

		//Se a Unidade for nula
		if (document.getElementById('und-solicitante') != null)
			if(document.getElementById('und-solicitante').selectedIndex == 0) {
				alert("Por favor selecione a Unidade!");
				return false;
			}

		//Se o Solicitante for nulo
		if (document.getElementById('solicitante') != null)
			if (document.getElementById('solicitante').value == "") {
				alert("Por favor selecione o Solicitante!");
				return false;
			}

		//Se a FR for nula
		if (document.getElementById('fonte') != null)
			if(document.getElementById('fonte').selectedIndex == 0) {
				alert("Por favor selecione a Fonte de Recursos!");
				return false;
			}

		//Se a Ação for nula
		if (document.getElementById('acao') != null)
			if(document.getElementById('acao').selectedIndex == 0) {
				alert("Por favor selecione a Ação!");
				return false;
			}

		//Se a Destinação do Imóvel for nula
		if (document.getElementById('destinacao-imovel') != null) {
			if (document.getElementById('destinacao-imovel').value == "") {
				alert("Por favor selecione a Destinação do Imóvel do Contrato!");
				return false;
			}
			if (document.getElementById('destinacao-imovel').value == "OUTRAS") {
				if (document.getElementById('outras-destinacoes').value == "") {
					alert("Por favor digite a Destinação do Imóvel do Contrato!");
					return false;
				}
			}
			if (document.getElementById('detalhes-destinacao').value == "") {
				alert("Por favor digite os Detalhes da Destinação do Imóvel do Contrato!");
				return false;
			}
		}

		//Se o Endereço do Imóvel for nulo
		if (document.getElementById('endereco-imovel') != null)
			if(document.getElementById('endereco-imovel').value == "") {
				alert("Por favor digite o Endereço do Imóvel do Contrato!");
				return false;
			}

		//Se a Regional for nula
		if (document.getElementById('regional') != null)
			if(document.getElementById('regional').selectedIndex == 0) {
				alert("Por favor selecione a Regional do Município onde está o Imóvel!");
				return false;
			}

		//Se o Município for nulo
		if (document.getElementById('municipio') != null)
			if(document.getElementById('municipio').value == "") {
				alert("Por favor selecione o Município onde está o Imóvel!");
				return false;
			}

		//Se a Descrição do Imóvel for nula
		if (document.getElementById('descricao-imovel') != null)
			if(document.getElementById('descricao-imovel').value == "") {
				alert("Por favor digite a Descrição do Imóvel do Contrato!");
				return false;
			}

		/*
		//Se a Melhoria do Imóvel for nula
		if (document.getElementById('melhorias-imovel') != null)
			if(document.getElementById('melhorias-imovel').value == "") {
				alert("Por favor digite as Melhorias a serem feitas no Imóvel do Contrato!");
				return false;
			}

		if (document.getElementById('parceria-imovel') != null)
			if(document.getElementById('parceria-imovel').value == "") {
				alert("Por favor digite como será a parceria no contrato caso exista.");
				return false;
			}
		*/

		if (document.getElementById('docs-faltantes-imovel') != null)
			if(document.getElementById('docs-faltantes-imovel').value == "") {
				alert("Por favor digite informações sobre os documentos necessários para a realização do Contrato!");
				return false;
			}

		if (document.getElementById('prazo-contrato') != null) {
			if(document.getElementById('prazo-contrato').value == "" ||
				document.getElementById('prazo-contrato').value == "0") {
				alert("Por favor digite o Prazo do Contrato!");
				return false;
			}
			if (document.getElementById('und-tempo-prazo') != null)
				if(document.getElementById('und-tempo-prazo').selectedIndex == 0) {
					alert("Por favor selecione a unidade de tempo do Prazo do Contrato!");
					return false;
				}
		}

		if (document.getElementById('data-inicio') != null)
			if (document.getElementById('data-inicio').value == "00/00/0000") {
				alert("Por favor selecione a data de início do contrato!");
				return false;
			}

		if (document.getElementById('data-fim') != null)
			if (document.getElementById('data-fim').value == "00/00/0000") {
				alert("Por favor selecione a data de encerramento do contrato!");
				return false;
			}

		if (document.getElementById('data-celebracao') != null)
			if (document.getElementById('data-celebracao').value == "00/00/0000") {
				alert("Por favor selecione a data de Celebração do Contrato!");
				return false;
			}

		if (document.getElementById('dia-pgto') != null) {

			if (document.getElementById('dia-pgto').value == "") {
				alert("Por favor digite o dia do Pagamento Mensal!");
				return false;
			}

			dia_pgto = document.getElementById('dia-pgto').value;
			dia_pgto = parseInt(dia_pgto);

			//alert(dia_pgto);

			if(dia_pgto < 1 || dia_pgto > 28) {
				alert("Por favor digite apenas valores entre 1 e 28 para o dia do Pagamento Mensal!");
				return false;
			}

		}

		if (document.getElementById('valor-pgto') != null) {

			valor_pgto = document.getElementById('valor-pgto').value;
			valor_pgto = remove(valor_pgto,".", "");
			valor_pgto = remove(valor_pgto,",", ".");
			valor_pgto = parseFloat(valor_pgto);

			if (valor_pgto <= 0) {
				alert("Por favor digite o Valor do Pagamento Mensal!");
				return false;
			}

		}

		if (document.getElementById('valor-total-pgto') != null) {

			valor_total_pgto = document.getElementById('valor-total-pgto').value;
			valor_total_pgto = remove(valor_total_pgto,".", "");
			valor_total_pgto = remove(valor_total_pgto,",", ".");
			valor_total_pgto = parseFloat(valor_total_pgto);

			if (valor_total_pgto <= 0) {
				alert("Por favor digite o Valor Total do Pagamento!");
				return false;
			}

			if (document.getElementById('valor-pgto') != null) {
				if (valor_pgto > valor_total_pgto) {
					alert("O Valor Total do Pagamento está menor que o Valor do Pagamento Mensal!");
					return false;
				}
			} else {
				alert("O Valor Total do Pagamento está menor que o Valor do Pagamento Mensal!");
				return false;
			}

		}

		//Se o CPF ou CNPJ for nulo
		if (document.getElementById('tipo-documento-cpf').checked) {

			if (document.getElementById('cpf') != null)
				if(document.getElementById('cpf').value == "") {
					alert("Por favor digite o CPF da outra parte no Contrato!");
					return false;
				}

			if (document.getElementById('rg') != null)
				if(document.getElementById('rg').value == "") {
					alert("Por favor digite o RG da outra parte no Contrato!");
					return false;
				}

			if (document.getElementById('rg-oe') != null)
				if(document.getElementById('rg-oe').value == "") {
					alert("Por favor digite o Orgão Emissor do RG da outra parte no Contrato!");
					return false;
				}

			if (document.getElementById('genero-m') != null &&
				document.getElementById('genero-f') != null)
				if (!document.getElementById('genero-m').checked &&
					!document.getElementById('genero-f').checked) {
					alert("Por favor selecione o sexo da outra parte no Contrato!");
					return false;
				}

			if (document.getElementById('estado-civil') != null)
				if(document.getElementById('estado-civil').value == "") {
					alert("Por favor digite o Estado Civil da outra parte no Contrato!");
					return false;
				}

			if (document.getElementById('ocupacao') != null)
				if(document.getElementById('ocupacao').value == "") {
					alert("Por favor digite a Ocupação da outra parte no Contrato!");
					return false;
				}

			if (document.getElementById('naturalidade') != null)
				if(document.getElementById('naturalidade').value == "") {
					alert("Por favor digite a Naturalidade da outra parte no Contrato!");
					return false;
				}

			if (document.getElementById('nacionalidade') != null)
				if(document.getElementById('nacionalidade').value == "") {
					alert("Por favor digite a Nacionalidade da outra parte no Contrato!");
					return false;
				}

		} else {

			if (document.getElementById('cnpj') != null)
				if(document.getElementById('cnpj').value == "") {
					alert("Por favor digite o CNPJ da outra parte no Contrato!");
					return false;
				}

			if (document.getElementById('nome-comercial') != null)
				if(document.getElementById('nome-comercial').value == "") {
					alert("Por favor digite o Nome Comercial (Fantasia) da outra parte no Contrato!");
					return false;
				}

		}

		//Se o Nome da outra parte for nulo
		if (document.getElementById('nome-outra-parte') != null)
			if(document.getElementById('nome-outra-parte').value == "") {
				alert("Por favor digite o nome da outra parte no Contrato!");
				return false;
			}

		//Se o Endereço da outra parte for nulo
		if (document.getElementById('endereco-outra-parte') != null)
			if(document.getElementById('endereco-outra-parte').value == "") {
				alert("Por favor digite o Endereço da outra parte no Contrato!");
				return false;
			}



		if (document.getElementById('banco') != null)
			if (document.getElementById('banco').value == "") {
				alert("Por favor digite o nome do Banco!");
				return false;
			}

		if (document.getElementById('agencia') != null)
			if (document.getElementById('agencia').value == "") {
				alert("Por favor digite o Código da Agência!");
				return false;
			}

		/*
		if (document.getElementById('agencia-digito') != null)
			if (document.getElementById('agencia-digito').value == "") {
				alert("Por favor digite o dígito do Código da Agência!");
				return false;
			}
		*/

		if (document.getElementById('cc') != null)
			if (document.getElementById('cc').value == "") {
				alert("Por favor digite o Código da Conta Corrente!");
				return false;
			}

		if (document.getElementById('cc-digito') != null)
			if (document.getElementById('cc-digito').value == "") {
				alert("Por favor digite o dígito do Código da Conta Corrente!");
				return false;
			}

		if (document.getElementById('titular-conta-recebedor').checked) {

			if (document.getElementById('tipo-documento-cpf-titular-conta').checked) {

				if (document.getElementById('cpf-titular-conta') != null)
					if (document.getElementById('cpf-titular-conta').value == "") {
						alert("Por favor digite o CPF do Titular da Conta!");
						return false;
					}

				if (document.getElementById('rg-titular-conta') != null)
					if (document.getElementById('rg-titular-conta').value == "") {
						alert("Por favor digite o RG do Titular da Conta!");
						return false;
					}

				if (document.getElementById('rg-oe-titular-conta') != null)
					if (document.getElementById('rg-oe-titular-conta').value == "") {
						alert("Por favor digite o Orgão Emissor do RG do Titular da Conta!");
						return false;
					}

				if (document.getElementById('genero-m-titular-conta') != null &&
					document.getElementById('genero-f-titular-conta') != null)
					if (!document.getElementById('genero-m-titular-conta').checked &&
						!document.getElementById('genero-f-titular-conta').checked) {
						alert("Por favor selecione o sexo do titular da Conta!");
						return false;
					}

				if (document.getElementById('estado-civil-titular-conta') != null)
					if(document.getElementById('estado-civil-titular-conta').value == "") {
						alert("Por favor digite o Estado Civil do Titular da Conta!");
						return false;
					}

				if (document.getElementById('ocupacao-titular-conta') != null)
					if(document.getElementById('ocupacao-titular-conta').value == "") {
						alert("Por favor digite a Ocupação do Titular da Conta!");
						return false;
					}

				if (document.getElementById('naturalidade-titular-conta') != null)
					if(document.getElementById('naturalidade-titular-conta').value == "") {
						alert("Por favor digite a Naturalidade do Titular da Conta!");
						return false;
					}

				if (document.getElementById('nacionalidade-titular-conta') != null)
					if(document.getElementById('nacionalidade-titular-conta').value == "") {
						alert("Por favor digite a Nacionalidade do Titular da Conta!");
						return false;
					}

			} else {

				if (document.getElementById('cnpj-titular-conta') != null)
					if(document.getElementById('cnpj-titular-conta').value == "") {
						alert("Por favor digite o CNPJ do Titular da Conta!");
						return false;
					}

				if (document.getElementById('nome-comercial-titular-conta') != null)
					if(document.getElementById('nome-comercial-titular-conta').value == "") {
						alert("Por favor digite o Nome Comercial (Fantasia) do Titular da Conta!");
						return false;
					}

			}

			if (document.getElementById('nome-titular-conta') != null)
				if (document.getElementById('nome-titular-conta').value == "") {
					alert("Por favor digite o nome do Titular da Conta!");
					return false;
				}

			if (document.getElementById('endereco-titular-conta') != null)
				if (document.getElementById('endereco-titular-conta').value == "") {
					alert("Por favor digite o endereço residencial do Titular da Conta!");
					return false;
				}

		}



		if (document.getElementById('possue-representante-sim').checked ||
			document.getElementById('tipo-documento-cnpj').checked) {

			if (document.getElementById('cpf-representante') != null)
				if (document.getElementById('cpf-representante').value == "") {
					alert("Por favor digite o CPF do Representante!");
					return false;
				}

			if (document.getElementById('rg-representante') != null)
				if (document.getElementById('rg-representante').value == "") {
					alert("Por favor digite o RG do Representante!");
					return false;
				}

			if (document.getElementById('rg-oe-representante') != null)
				if (document.getElementById('rg-oe-representante').value == "") {
					alert("Por favor digite o Orgão Emissor do RG do Representante!");
					return false;
				}

			if (document.getElementById('genero-m-representante') != null &&
				document.getElementById('genero-f-representante') != null)
				if (!document.getElementById('genero-m-representante').checked &&
					!document.getElementById('genero-f-representante').checked) {
					alert("Por favor selecione o sexo do Representante!");
					return false;
				}

			if (document.getElementById('estado-civil-representante') != null)
				if(document.getElementById('estado-civil-representante').value == "") {
					alert("Por favor digite o Estado Civil do Representante!");
					return false;
				}

			if (document.getElementById('ocupacao-representante') != null)
				if(document.getElementById('ocupacao-representante').value == "") {
					alert("Por favor digite a Ocupação do Representante!");
					return false;
				}

			if (document.getElementById('naturalidade-representante') != null)
				if(document.getElementById('naturalidade-representante').value == "") {
					alert("Por favor digite a Naturalidade do Representante!");
					return false;
				}

			if (document.getElementById('nacionalidade-representante') != null)
				if(document.getElementById('nacionalidade-representante').value == "") {
					alert("Por favor digite a Nacionalidade do Representante!");
					return false;
				}

			if (document.getElementById('nome-representante') != null)
				if (document.getElementById('nome-representante').value == "") {
					alert("Por favor digite o nome do Representante!");
					return false;
				}

			if (document.getElementById('endereco-representante') != null)
				if (document.getElementById('endereco-representante').value == "") {
					alert("Por favor digite o endereço residencial do Representante!");
					return false;
				}

		}

	}

	resposta = confirm("Você tem certeza que deseja submeter esta avaliação?");

	if (resposta) {
		window.document.formulario_avaliar_aluguel.submit();
	} else {
		//alert("A Avaliação falhou! Contate o suporte!");
		return false;
	}

}

var permitir_empenhar_aluguel = false;

function empenharAluguel() {

	/*
	if (document.getElementById('empenhado').value == "nao") {
		alert("Esta Solicitação de Aluguel ainda não foi empenhada!\nPara submeter esta avaliação empenhe-a,\nou encaminhe-a a um usuário que tenha permissão para\nEmpenhar Solicitações de Aluguel!");
		return false;
	}
	*/

	if (permitir_empenhar_aluguel) {

		if (document.getElementById('data-emissao').value == "00/00/0000") {
			alert("Por favor selecione a data de emissão do Empenho!");
			return false;
		}

		if (document.getElementById('nota-empenho').value == "") {
			alert("Por favor digite a Nota de Empenho!");
			return false;
		}

		valor_empenho = document.getElementById('valor-empenho').value;
		valor_empenho = remove(valor_empenho,".", "");
		valor_empenho = remove(valor_empenho,",", ".");
		valor_empenho = parseFloat(valor_empenho);
		//alert(valor_empenho);

		if (valor_empenho <= 0) {
			alert("Por favor digite o Valor do Empenho!");
			return false;
		}

	}

	resposta = confirm("Você tem certeza que deseja submeter este empenho?");

	if (resposta) {
		window.document.formulario_avaliar_aluguel.submit();
	} else {
		return false;
	}

}

var permitir_realizar_tarefa_contrato_aluguel = false;

function realizarTarefaContratoAluguel(tipo, texto_1, texto_2) {

	//alert("Entrou!");

	if (permitir_realizar_tarefa_contrato_aluguel) {

		var arrayElements = document.getElementsByTagName('input');

		existe_checks = false;
		existe_checks_validos = false;

		for (var i = 0; i < arrayElements.length; i++) {
			if (arrayElements[i].type == 'radio') {
				if (arrayElements[i].checked == true) {
					existe_checks = true;
					if (arrayElements[i].id.indexOf(tipo) != -1) {
						existe_checks_validos = true;
					}
				}
			}
		}

		if (!existe_checks) {
			alert(texto_1)
			return false;
		}

		if (!existe_checks_validos) {
			alert(texto_2)
			return false;
		}

	}

	resposta = confirm("Você tem certeza que deseja submeter esta requisição?");

	if (resposta) {
		window.document.formulario_gerar_contrato_aluguel.submit();
	} else {
		return false;
	}

}

