function mascara(o, f) {
	v_obj = o
	v_fun = f
	setTimeout("execmascara()", 1)
}
function execmascara() {
	v_obj.value = v_fun(v_obj.value)
}
function enviarEmailContato() {
	if(document.form.txtNome.value==''){
		alert('Informe um nome!');
		document.form.txtNome.focus();
	}
	else if(document.form.txtEmail.value==''){
		alert('Informe um e-mail!');
		document.form.txtEmail.focus();
	}
	else if(validaEmail(document.form.txtEmail.value)==false){
		alert('E-mail inválido');
		document.form.txtEmail.value = '';
	}
	else if(document.form.txtMsg.value==''){
		alert('Digite uma mensagem!');
		document.form.txtMsg.focus();
	}
	else{
		document.form.action='/agencia/contato';
		document.form.submit();
	}
}

function validaEmail(Email){
	var filter = /^(([a-zA-Z0-9_-])+(([\.\])+([a-zA-Z0-9_-]{0,1})))+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
	var arrayEmail = Email.split(";"); //Separa os email 
	for (var i=0;i < arrayEmail.length; i++){ //varre a lista de emails 
		if ( !filter.test(arrayEmail[i]) ){ 
			return false; //se tiver erro sai com false 
		}
		else{ 
			return true; // se nao achou erro retorrna verdadeiro 
		}
	}
}

function escondeDiv(div) {
	document.getElementById(div).innerHTML = "";
	document.getElementById(div).style.display = "none";
}

function validandoEmail(email) {
	exp = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/
	if (!exp.test(email.value)) {
		location.href = "javascript:scroll(0,0)";
		document.getElementById("DivMsg").style.display = "block";
		document.getElementById("DivMsg").innerHTML = "Email Inválido!";
		setTimeout('escondeDiv("DivMsg")', 3000);
		email.value = "";
	}
}
function cnpj(v){
	v=v.replace(/\D/g,"")
	v=v.replace(/^(\d{2})(\d)/,"$1.$2") 
	v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") 
	v=v.replace(/\.(\d{3})(\d)/,".$1/$2") 
	v=v.replace(/(\d{4})(\d)/,"$1-$2")
	return v
}
function cpf(v){
	v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
	v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	//de novo (para o segundo bloco de números)
	v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
	return v
}
function telefone(v){
	v=v.replace(/\D/g,"") 
	v=v.replace(/^(\d\d)(\d)/g,"($1) $2") 
	v=v.replace(/(\d{4})(\d)/,"$1-$2")
	return v
}
function data(v){ 
	v=v.replace(/\D/g,"")
	v=v.replace(/(\d{2})(\d)/,"$1/$2")
	v=v.replace(/(\d{2})(\d)/,"$1/$2")
	return v    }
function cep(v){
	v=v.replace(/\D/g,"") 
	v=v.replace(/^(\d{5})(\d)/,"$1-$2") 
	return v
}
function acessarSGC(){
	if(document.formSGC.txtCPF.value==''){
		alert('Digite seu CPF!');
		document.formSGC.txtCPF.focus();
	}
	else if(document.formSGC.txtSenha.value==''){
		alert('Digite sua senha!');
		document.formSGC.txtSenha.focus();
	}
	else{
		document.formSGC.action='http://190.120.238.190:8180/stdweb/acesso?ac=verificar_acesso';
		document.formSGC.submit();
	} 
}
function acessar(e){
	var tecla = 0;
	var key=e.keyCode || e.which;
	if (key==13){
		if(document.formLogin.txtCPF.value==''&&document.formLogin.txtCNPJ.value==''){
			alert('Digite seu CPF ou CNPJ!');
		}
		else{
			document.formLogin.action='agencia?ac=sistemacliente';
			document.formLogin.submit();
		}
	} 
}
function acessarBotao(){
	if(document.formLogin.txtCPF.value==''&&document.formLogin.txtCNPJ.value==''){
		alert('Digite seu CPF ou CNPJ!');
	}
	else{
		document.formLogin.action='agencia?ac=sistemacliente';
		document.formLogin.submit();
	}
}
function gerarBoleto(idCliente, idBoleto){
	document.formBoleto.action='aarq?idCliente='+idCliente+'&idBoleto='+idBoleto;
	document.formBoleto.submit();
}
function finPortal(){
	document.formBoleto.action='agencia?ac=sistemacliente';
	document.formBoleto.submit();
}
