previdencia = {
	beneficiario : 0,
	perfil : 0,
	plano : 0,
	
	inicia : function(){
		this.beneficiario = FuncoesGerais.BuscaParametro('beneficiario');
		this.perfil = FuncoesGerais.BuscaParametro('perfil');
		this.plano = FuncoesGerais.BuscaParametro('plano');
		if (this.beneficiario != ''){
			FuncoesGerais.SelecionaValorRadio(document.form1.beneficiario, this.beneficiario);
			FuncoesGerais.SelecionaValorRadio(document.form1.perfil, this.perfil);
			FuncoesGerais.SelecionaValorRadio(document.form1.plano, this.plano);
			if (this.beneficiario == 2){
				FuncoesGerais.HabilitaRadio(document.form1.perfil, false);
			}else if (this.beneficiario == 3){
				FuncoesGerais.HabilitaRadio(document.form1.perfil, true);
				FuncoesGerais.HabilitaRadio(document.form1.plano, true);
			}
			this.monta_resultado();
		}
	},
	
	envia : function(){
		document.getElementById('table_previdencia').style.display = 'none';
		this.beneficiario = FuncoesGerais.RetornaValorRadio(document.form1.beneficiario);
		this.perfil = FuncoesGerais.RetornaValorRadio(document.form1.perfil);
		this.plano = FuncoesGerais.RetornaValorRadio(document.form1.plano);
		msg = this.valida_envio();
		if (msg == ''){
			this.monta_resultado();
			window.location.href='#bottom_busca';
		}else{
			alert(msg);
		}
	},
	
	valida_envio : function(){
		msg = '';
		if (FuncoesGerais.RetornaValorRadio(document.form1.beneficiario) == ''){
			msg = 'Selecione o Plano';
		}else if (FuncoesGerais.RetornaValorRadio(document.form1.perfil) == '' && this.beneficiario < 3){
			msg = 'Selecione o Perfil';
		}else if (FuncoesGerais.RetornaValorRadio(document.form1.plano) == '' && this.beneficiario < 3){
			msg = 'Selecione a Modalidade';
		}
		return msg;
	},
	
	habilita_radio : function(beneficiario){
		if (beneficiario == 1){
			FuncoesGerais.HabilitaRadio(document.form1.perfil, false);
			FuncoesGerais.HabilitaRadio(document.form1.plano, false);
		}else if (beneficiario == 2){
			FuncoesGerais.HabilitaRadio(document.form1.perfil, false);
			FuncoesGerais.HabilitaRadio(document.form1.plano, false);
			FuncoesGerais.HabilitaRadio(document.form1.perfil, false);
		}else if (beneficiario == 3){
			FuncoesGerais.HabilitaRadio(document.form1.perfil, true);
			FuncoesGerais.HabilitaRadio(document.form1.plano, true);
			FuncoesGerais.DesmarcaRadio(document.form1.perfil);
			FuncoesGerais.DesmarcaRadio(document.form1.plano);
		}
	},
	
	monta_resultado : function(){
		this.esconde_colunas();
		document.getElementById('table_previdencia').style.display = '';
		if (this.beneficiario == 1){
			if (this.plano == 1){
				if (this.perfil == 1){
					document.getElementById('tr1').style.display = '';
					document.getElementById('tr2').style.display = '';
				}else if (this.perfil == 2){
					document.getElementById('tr3').style.display = '';
				}else if (this.perfil == 3){
					document.getElementById('tr16').style.display = '';
					document.getElementById('tr20').style.display = '';
				}
			}else if (this.plano == 2){
				if (this.perfil == 1){
					document.getElementById('tr5').style.display = '';
					document.getElementById('tr6').style.display = '';
				}else if (this.perfil == 2){
					document.getElementById('tr7').style.display = '';
				}else if (this.perfil == 3){
					document.getElementById('tr17').style.display = '';
					document.getElementById('tr8').style.display = '';
				}
			}
		}else if (this.beneficiario == 2){
			if (this.plano == 1){
				if (this.perfil == 1){
					document.getElementById('tr9').style.display = '';
				}else if (this.perfil == 2){
					document.getElementById('tr10').style.display = '';
				}else if (this.perfil == 3){
					document.getElementById('tr4').style.display = '';
					
				}
			}else if (this.plano == 2){
				if (this.perfil == 1){
					document.getElementById('tr11').style.display = '';
				}else if (this.perfil == 2){
					document.getElementById('tr12').style.display = '';
				}else if (this.perfil == 3){
					document.getElementById('tr14').style.display = '';
					
				}
			}
		
		}else if (this.beneficiario == 3){
			//if (this.plano ==1){
				document.getElementById('tr18').style.display = '';
		//	}
			//else if (this.plano ==2){
				//document.getElementById('tr19').style.display = '';
		//	}
			
		}
		
	},
	
	esconde_colunas : function(){
		for (c=1;c<21;c++){
			document.getElementById('tr'+c).style.display = 'none';
		}
	}
}