dia = new Date();
ano = dia.getYear();
if (ano < 2000) // correçao para browsers que retornam 100 no ano 2000
{
	ano = 1900 + dia.getYear();
}

mes = new Array("Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro")
dia_semana = new Array("Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado");

function escreveData()
{
	document.writeln(dia_semana[dia.getDay()] + ", " + dia.getDate() + " de " +  mes[dia.getMonth()] + " de " + ano);
}

function indique()
{
	window.open('indica.php', 'indica', 'scrollbars=yes,toolbar=no,scrolling=yes,location=no,directories=no,status=no,menubar=no,resizable=no,top=100,width=380,height=260,left=170');
}

function simulacao(tipo)
{
	window.open('form_simulador.php?tipo='+tipo, 'simulacao', 'scrollbars=yes,toolbar=no,scrolling=yes,location=no,directories=no,status=no,menubar=no,resizable=no,top=100,width=456,height=360,left=170');
}

function simulador()
{
	window.open('simulador.php', 'simulador', 'scrollbars=yes,toolbar=no,scrolling=yes,location=no,directories=no,status=no,menubar=no,resizable=no,top=100,width=456,height=360,left=170');
}

function tabelaCustas()
{
	window.open('tabelaCustas.php', 'tabelaCustas', 'scrollbars=yes,toolbar=no,scrolling=yes,location=no,directories=no,status=no,menubar=no,resizable=no,top=100,width=550,height=435,left=170');
}

function assinarNewsletter()
{
	window.open('assinarNewsletter.php', 'assinarNewsletter', 'scrollbars=yes,toolbar=no,scrolling=yes,location=no,directories=no,status=no,menubar=no,resizable=no,top=100,width=420,height=245,left=170');
}

function mapa()
{
	window.open('mapa.php', 'mapa', 'scrollbars=yes,toolbar=no,scrolling=yes,location=no,directories=no,status=no,menubar=no,resizable=no,top=10,width=624,height=426,left=10');
}

function addFav()
{
	var url = "http://www.cerd-rj.com.br";
	var title = "CERD - Central de Registro de Documentos";
	if(window.sidebar) window.sidebar.addPanel(title, url,"");
	else if(window.opera && window.print)
	{
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',title);
		mbm.click();
	}
		else if(document.all){window.external.AddFavorite(url, title);
	}
}

//função para checar cadastro
//function checar_fichaCadPF(fichaCadPF)
//{
//	if(fichaCadPF.trabalha[0].checked == true)
//	{
//		if(document.getElementById("empresaTrabalha").value == "")
//		{
//			alert("Por favor preencha o campo: Empresa em que trabalha.");
//			document.getElementById("empresaTrabalha").focus();
//			return (false);
//		}
//	}
//}

function checarCampos(id)
{
	var campo = document.getElementById(id);
	if(campo.value.length == 0)
	{
		alert("Campo obrigatório!");
		campo.style.backgroundColor = "#EFEFEF";
		campo.style.border = "1px solid #FF0000";
	}
	else
	{
		campo.style.backgroundColor = "#FFFFFF";
		campo.style.border = "1px solid #e0dfe3";
	}
}

function mascCEP(id)
{
	var campo = document.getElementById(id);

	if(campo.value.length == "5")
	{
		campo.value += "-";
	}
	
	if(campo.value.length == "9")
	{
		campo.value;
	}
}

function mascDATA(id)
{
	var campo = document.getElementById(id);

	if(campo.value.length == "2")
	{
		campo.value += "/";
	}

	if(campo.value.length == "5")
	{
		campo.value += "/";
	}
	
	if(campo.value.length == "10")
	{
		campo.value;
	}
}

function mascTEL(id)
{
	var campo = document.getElementById(id);

	if(campo.value.length == "4")
	{
		campo.value += "-";
	}
	
	if(campo.value.length == "9")
	{
		campo.value;
	}
}


//função para só digitar números
function sem_letras(){
    if ((window.event.keyCode < 48) | (window.event.keyCode > 57)){
        window.event.keyCode = 0
    }
}
