document.write("<meta http-equiv='Pragma' content='no-cache'>");
document.write("<meta http-equiv='Expires' content='Thu, 01 Jan 1970 00:00:00 GMT'>");
document.write("<meta http-equiv='Cache-Control' content='no-store'>");

function posicionaCursor(valor)
{
	setSelectionRange(valor, valor.value.length, valor.value.length); 
}

function calculaPremioVida(capital,taxa,campoPremioTotal,campoPremioLiquido,campoIof)
{
	document.getElementById("iFrameCalculaPremio").src = "funcoes/calculaPremioVida.php?capital="+capital+"&taxa="+taxa+"&campoPremioTotal="+campoPremioTotal+"&campoPremioLiquido="+campoPremioLiquido+"&campoIof="+campoIof+"";
}

function calculaPremioOutros(campoPremioTotal,premioLiquido,custo,juros,iof)
{
	document.getElementById("iFrameCalculaPremio").src = "funcoes/calculaPremioOutros.php?campoPremioTotal="+campoPremioTotal+"&premioLiquido="+premioLiquido+"&custo="+custo+"&juros="+juros+"&iof="+iof+"";
}

function parcelamentoPremio(campoValorTotal,valor,valorTotal,tipo)
{
	document.getElementById("iFrameParcelamentoPremio").src = "funcoes/parcelamentoPremio.php?campoValorTotal="+campoValorTotal+"&valor="+valor+"&valorTotal="+valorTotal+"&tipo="+tipo+"";
}

function dadosParcela(premioTotal,qtdParcelas,dataIniVig,ramo,tipo)
{
	data = dataIniVig.substring(0,2) + dataIniVig.substring(3,5) + dataIniVig.substring(6,10);
	document.getElementById("iFrameDadosParcela").src = "funcoes/dadosParcela.php?premioTotal="+premioTotal+"&qtdParcelas="+qtdParcelas+"&dataIniVig="+data+"&ramo="+ramo+"&tipo="+tipo+"";
}

function somaData(dataIniVig)
{
	data = dataIniVig.substring(0,2) + dataIniVig.substring(3,5) + dataIniVig.substring(6,10);
	document.getElementById("iFrameSomaData").src = "funcoes/somaData.php?dataIniVig="+data+"";
}

function funPorcentagemTotal(campoValorTotal,valor,valorTotal,tipo,pagina)
{
	document.getElementById("iFrameBeneficiarios").src = pagina+"?campoValorTotal="+campoValorTotal+"&valor="+valor+"&valorTotal="+valorTotal+"&tipo="+tipo+"";
}

function populaComboRefresh(combo,codigo,campo_codigo,campo_descricao,valorComboOriginal1,valorComboOriginal2,valorComboOriginal3,valorComboOriginal4,tipoSelect)
{
	limpaCombo("parent",combo);
	document.getElementById("iFramePopulaCombo").src = "funcoes/populaCombo.php?nome_combobox="+combo+"&codigo="+codigo+"&campo_codigo="+campo_codigo+"&campo_descricao="+campo_descricao+"&valorComboOriginal1="+valorComboOriginal1+"&valorComboOriginal2="+valorComboOriginal2+"&valorComboOriginal3="+valorComboOriginal3+"&valorComboOriginal4="+valorComboOriginal4+"&tipo=parent&tipoSelect="+tipoSelect+"";
}

function populaComboRefresh2(combo1,combo2,iframe1,iframe2,codigo1,codigo2,campo_codigo1,campo_codigo2,campo_descricao1,campo_descricao2,valorComboOriginal1,valorComboOriginal2,valorComboOriginal3,valorComboOriginal4,tipoSelect1,tipoSelect2)
{
	limpaCombo("parent",combo1);
	limpaCombo("parent",combo2);
	iframe1.src = "funcoes/populaCombo.php?nome_combobox="+combo1+"&codigo="+codigo1+"&campo_codigo="+campo_codigo1+"&campo_descricao="+campo_descricao1+"&valorComboOriginal1="+valorComboOriginal1+"&valorComboOriginal2="+valorComboOriginal2+"&valorComboOriginal3="+valorComboOriginal3+"&valorComboOriginal4="+valorComboOriginal4+"&tipo=parent&tipoSelect="+tipoSelect1+"";
	iframe2.src = "funcoes/populaCombo.php?nome_combobox="+combo2+"&codigo="+codigo2+"&campo_codigo="+campo_codigo2+"&campo_descricao="+campo_descricao2+"&valorComboOriginal1="+valorComboOriginal1+"&valorComboOriginal2="+valorComboOriginal2+"&valorComboOriginal3="+valorComboOriginal3+"&valorComboOriginal4="+valorComboOriginal4+"&tipo=parent&tipoSelect="+tipoSelect2+"";
}

function abreLst(nome_combobox_alterar,nome_combobox_codigo,titulo,str_codigo,str_nome,sql,sqladicional)
{
	codigo = document.getElementById(nome_combobox_codigo).value;
	index = document.getElementById(nome_combobox_alterar).selectedIndex;
	sql= sql+codigo+sqladicional;
	newwindow = window.open("lstPadraoSimples.php?nome_combobox_alterar="+nome_combobox_alterar+"&codigo="+codigo+"&str_codigo="+str_codigo+"&str_nome="+str_nome+"&titulo="+titulo+"&sql="+sql+"&sql=parent","filha","height=400,width=450,status=no,toolbar=no,menubar=no,scrollbars=yes");
	//document.getElementById(nome_combobox_alterar).focus();
	setTimeout("document.getElementById("+nome_combobox_alterar+").focus();",0);
	newwindow.focus();
}

function limpaCombo(tipo,nome_combobox)
{  
	var campo;
	campo = eval(tipo + ".document.getElementById('" + nome_combobox + "')");
	while(campo.options.length > 0)
		campo.options[(campo.options.length - 1)] = null;
	
	campo.options[0]= new Option("Selecione","null");
	campo.selectedIndex = 0;
}


function AbreJanela(url,bEsconder) {
   if (isNaN(bEsconder))
	   var bEsconder=false;

   var browser = navigator.appName;
   var versao = parseInt(navigator.appVersion);
   if(versao <4 && browser == "Microsoft Internet Explorer") {
      alert('Esta versão do seu browser não suporta os comandos JavaScript presentes nesta página, o que poderá causar alguma mensagem de erro.Obrigado!');
      return false;
   }
   if (bEsconder==false)
     if(browser == 'Netscape') {
        return window.open(url,"","directories=no,height=200,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=400,top=10,left=365");
      }
      else {
         if(versao > 4) {
            return window.open(url,"","directories=no,height=200,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=400,top=10,left=365");
         }
         else {
            return window.open(url,"","directories=no,height=200,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=400,top=10,left=365");
         }
      }
    else
       return window.open("","","directories=no,border=0,color=#ffffff,height=5,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=5,top=0,left=4000");
}

function Redir(strUrl,nTempo)
{
   setTimeout("window.location.href=\'"+strUrl+"\'",nTempo);
   return;
}

function Redireciona(strUrl,nTempo)
{
  strInicio = new Date();
  nInicio  = strInicio.getTime();
  nAtual   = 0;
  while ((nInicio+nTempo*1000)>nAtual )
  {
     strHora = new Date();
     nAtual  = strHora.getTime();
  }
  window.location.href=strUrl;
  return;
}

function TrocouUF(chAcao)
{
   if (document.forms[0].UFINICIAL.value != document.forms[0].strUF.value)
   {
      document.forms[0].acao.value=chAcao;
      document.forms[0].submit();
   }
}

function Trunca(objCampo,nBytes)
{
   //alert(objCampo.value.length);	 
   objCampo.value=objCampo.value.substring(0,nBytes);
   return true;
}

function FechaJanela()
{
  //WB.ExecWB(45,2); controle activeX que não se comporta muito bem 
  window.close();
}

function Sexo(objCampo)
{
   var chValor=objCampo.value.toUpperCase();

   if (chValor=="M" || chValor=="F")
   {
      objCampo.value=chValor;
      return true;
   }
   else
   {
      objCampo.value="";
      objCampo.focus();
      alert("Somente é permitido informar M(asculino) ou F(eminino)");
      return false;
   }
}

function Imprimir() 
{  
   var NS = (navigator.appName == "Netscape");
   var VERSION = parseInt(navigator.appVersion);
   if (NS || VERSION <=5) 
   {
       self.print() ;  
   } 
   else
   {
       var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
       document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
       WebBrowser1.ExecWB(6, 2);
       WebBrowser1.outerHTML = "";  
   }
}

function Calculadora()
{
   var browser = navigator.appName;
   var versao = parseInt(navigator.appVersion);
   var url="calculadora.html";
   if(versao <4 && browser == "Microsoft Internet Explorer") {
      alert('Esta versão do seu browser não suporta os comandos JavaScript presentes nesta página, o que poderá causar alguma mensagem de erro.Obrigado!');
      return false;
   }
   if(browser == 'Netscape') {
       window.open(url,null,"directories=no,height=190,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,width=365,top=10,left=355");
   }
   else {
      if(versao > 4) {
         window.open(url,null,"directories=no,height=190,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,width=325,top=10,left=355");
      }
      else {
         window.open(url,null,"directories=no,height=190,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,width=325,top=10,left=355");
      }
   }
   return true;
}

function atualizapagina(pagina,nform)
{
   document.forms[nform].action=pagina;
   document.forms[nform].submit();
   return true;
}


function Dimensiona(nReferencia,nTipo)
{
   if (nTipo==1)
      return (nReferencia*screen.width/800);
   else
   {
	 nAjuste=(screen.height-600)/2;
	 return (nReferencia*screen.height/600 + nAjuste);
   }
}

function up()
{
   if (!document.layers) 
      return;
   if (scrolldoc.top<0)
      scrolldoc.top+=10;
   temp2=setTimeout("up()",50);
}

function down()
{
   if (!document.layers) 
      return;
   if (scrolldoc.top-150>=scrolldoc.document.height*-1)
      scrolldoc.top-=10;
   temp=setTimeout("down()",50);
}

function pega_cep(valor)
{ 
	 n_url = 'cep.php?cep='+valor;
	 document.getElementById('Divcep').innerHTML='<iframe src="'+ n_url + '" name="contato" width="100" height="100" marginwidth=0 marginheight=0 frameborder=1 scrolling=yes align="default"> </iframe>';
     return;
}

function mostraDocumento()
{
	if (document.getElementById('tipdocCnpj').checked) 
	{
		document.getElementById('trcnpj').style.display="block";
		document.getElementById('trcpf').style.display="none";
	}
	if (document.getElementById('tipdocCpf').checked) 
	{
		document.getElementById('trcnpj').style.display="none";
		document.getElementById('trcpf').style.display="block";
	}
}

function arrumaValor(valor)
{
	valorAux = "";
	for(w=0;w<valor.value.length;w++)
	{
		if(valor.value.charAt(w) != ".")
		{
			if(valor.value.charAt(w) == ",")
				valorAux = valorAux + ".";
			else
				valorAux = valorAux + valor.value.charAt(w);
		}
	}
	return valorAux;
}

function zeraValor(valor,nomecampo,e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;

	campo = eval("document.getElementById('" + nomecampo + "')");
	if (tecla == 46)
	{
		campo.value = "0,00";
		return;
	}
	
	if (valor.value == "")
	{
		campo = eval("document.getElementById('" + nomecampo + "')");
		campo.value = "0,00";
	}
}

function setSelectionRange(input, selectionStart, selectionEnd) {
	if (input.setSelectionRange) 
	{
		input.focus();
		input.setSelectionRange(selectionStart, selectionEnd);
	}
	else if (input.createTextRange) 
	{
		var range = input.createTextRange();
		range.collapse(true);
		range.moveEnd('character', selectionEnd);
		range.moveStart('character', selectionStart);
		range.select();
	}
}

