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")

function escreveData()
{
	document.writeln("Rio de Janeiro, " + dia.getDate() + " de " + mes[dia.getMonth()] + " de " + ano);
}

function imprimirBoleto(id)
{
	window.open('funcoes/boleto_bradesco.php?boleto=' + id, 'imprimirBoleto', 'scrollbars=yes, toolbar=yes, scrolling=yes, location=no, directories=yes, status=yes, menubar=yes, resizable=no, top=0, width=800,height=600, left=0');
}

function portalTISS(id)
{
	window.open(id, "","channelmode,scrollbars")
}

function fechaDIV(id)
{
	$('#aviso').hide('slow');
}

//Função para mudar o e-mail de destino
function mudaDestino(campo)
{
	var form = document.forms["contato"];

	selecionou = campo.selectedIndex;

	if(campo.options[selecionou].value == "Beneficiários e Prestadores")
	{
		var email = "operadora@climol.com.br";
	}
	else
	{
		var email = "climol@climol.com.br";
	}
	
	form.email_dest.value = email;
}


//Função para Validar E-mail
function checkEmail(str)
{
	var at="@"; var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (lat<1 || lat==lstr)
	{
		return false;
	}	//no @ or a leading @ or @ at the end
	
	if ( ldot<1 ||  ldot==lstr)
	{
		return false;
	} //no . or a leading . or . at the end
	
	if (str.indexOf(at,(lat+1))!=-1)
	{
		return false;
	}	//more than one @		
	
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		return false;
	}
	
	if (str.indexOf(dot,(lat+2))==-1)
	{
		return false;
	}
	
	if (str.indexOf(" ")!=-1)
	{
		return false;
	}	//no blank
	
	return true;
}

// Função para Validar Fale Conosco
function validate()
{
	var form = document.forms["contato"];
	
	if (form.Nome.value == "")
	{
		window.alert("Preencha o campo nome.");
		form.Nome.focus();
		return false;
	}
	
	if (!checkEmail(form.Email.value))
	{
		alert("Verifique o seu endereço de e-mail.");
		form.Email.focus();
		return false;
	}
	
	if (form.Cidade_UF.value == "")
	{
		alert("Preencha o campo cidade e UF.");
		form.Cidade_UF.focus();
		return false;
	}

	if (form.Telefone.value == "")
	{
		alert("Preencha o campo telefone.");
		form.Telefone.focus();
		return false;
	}
	
	if (form.Mensagem.value == "")
	{
		alert("Preencha o campo mensagem.");
		form.Mensagem.focus();
		return false;
	}
	
	return true;
}


// Função para Validar Via Boleto
function validate_boleto()
{
	var form = document.forms["via_boleto"];
	
	if (form.matricula.value == "" && form.cpf.value == "")
	{
		window.alert("Preencha o campo matrícula ou CPF.");
		form.matricula.focus();
		return false;
	}
	
	return true;
}

//FUNÇÃO PARA FORMATAR MÁSCARA
function formataMatricula(src, mascara)
{
	var campo = src.value.length;
	var saida = mascara.substring(0,1);
	var texto = mascara.substring(campo);
	if(texto.substring(0,1) != saida)
	{
		src.value += texto.substring(0,1);
	}
}

//FUNÇÃO PARA CHECAR PREENCHIMENTO SÓ DE NÚMEROS
function somente_numero(campo){
var digits="0123456789"
var campo_temp 
	for (var i=0;i<campo.value.length;i++){
		campo_temp=campo.value.substring(i,i+1) 
		if (digits.indexOf(campo_temp)==-1){
			campo.value = campo.value.substring(0,i);
		}
	}
}
