function validaevento(fa){
    if(fa.titulo.value=="" || fa.horas.value=="" || fa.minutos.value=="" || fa.local.value=="" || fa.cidade.value=="" || fa.descricao.value==""){
		alert("Por favor, preencha todos os campos.");
        return false;
    }
}
 
function valida_EMAIL(campo) { 
	var goodEmail = campo.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
	if (goodEmail) { 
	return true; 
	}
	else { 
	return false; 
	} 
}

function validacontato(f){
    if(f.nome.value=="" ||
       f.email.value=="" ||
       f.mensagem.value==""){
        alert("Por favor, preencha todos os campos.");
        return false;
    }
}

function filtro_SoNumeros() { 
	if (event.keyCode < 48 || event.keyCode > 57) 
		event.returnValue = false; 
} 

function mascara_FONEFAX(Campo, teclapres) { 
	
	var tecla = teclapres.keyCode; 
	var vr = new String(Campo.value); 
	
	vr = vr.replace(".", ""); 
	vr = vr.replace(".", ""); 
	vr = vr.replace("/", ""); 
	vr = vr.replace("-", ""); 
	
	tam = vr.length + 1 ; 
	
	if (tam > 5) 
		Campo.value = vr.substr(0, 4) + '-' + vr.substr(4, tam); 
} 
 
function mascara_CEP(Campo, teclapres) { 
	var tecla = teclapres.keyCode; 
	var vr = new String(Campo.value);
	
	vr = vr.replace(".", ""); 
	vr = vr.replace(".", ""); 
	vr = vr.replace("/", ""); 
	vr = vr.replace("-", "");
	
	tam = vr.length + 1 ;
	if (tecla != 9 && tecla != 8) {
		if (tam > 5) 
			Campo.value = vr.substr(0, 5) + '-' +  vr.substr(5, tam);
	}
} 

function mascara_DATA(Campo, teclapres) {
	var tecla = teclapres.keyCode; 
	var vr = new String(Campo.value); 
	
	vr = vr.replace(".", ""); 
	vr = vr.replace("/", ""); 
	vr = vr.replace("-", ""); 
	
	tam = vr.length + 1; 
	
	if (tecla != 9 && tecla != 8) { 
		if (tam > 2 && tam < 4) 
			Campo.value = vr.substr(0, 2) + '/' + vr.substr(3, tam); 
		if (tam > 4 && tam < 11) 
			Campo.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(5,tam-4); 
		}
} 

function mascara_CNPJ(Campo, teclapres){ 
	var tecla = teclapres.keyCode; 
	var vr = new String(Campo.value); 
	
	vr = vr.replace(".", ""); 
	vr = vr.replace(".", ""); 
	vr = vr.replace("/", ""); 
	vr = vr.replace("-", ""); 
	
	tam = vr.length + 1 ; 
	
	if (tecla != 9 && tecla != 8) { 
		if (tam > 2 && tam < 6) 
			Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam); 
		if (tam >= 6 && tam < 9) 
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5); 
		if (tam >= 9 && tam < 13)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8); 
		if (tam >= 13 && tam < 15)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
	}
} 

function mascara_CPF(Campo, teclapres) { 
	var tecla = teclapres.keyCode; 
	var vr = new String(Campo.value);
	 
	vr = vr.replace(".", ""); 
	vr = vr.replace(".", ""); 
	vr = vr.replace("-", "");
	
	tam = vr.length + 1; 
	
	if (tecla != 9 && tecla != 8) { 
	if (tam > 3 && tam < 7) 
		Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam); 
	if (tam >= 7 && tam <10) 
		Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6); 
	if (tam >= 10 && tam < 12)
		Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
	}
} 

function valida_CPF(cpf) {
	var i; 

	cpf = cpf.replace(".", ""); 
	cpf = cpf.replace(".", ""); 
	cpf = cpf.replace("/", ""); 
	cpf = cpf.replace("-", ""); 
	
	var c = cpf.substr(0,9); 
	var dv = cpf.substr(9,2); 
	
	var d1 = 0; 
	for (i = 0; i < 9; i++) { 
		d1 += c.charAt(i)*(10-i);
	} 
	d1 = 11 - (d1 % 11);
	if (d1 > 9) 
		d1 = 0; 
		d2 = d1 * 2; 
	for (i = 0; i < 9; i++) {
		d2 += c.charAt(i)*(11-i); 
	} 
	d2 = 11 - (d2 % 11); 
	if (d2 > 9) 
		d2 = 0; 
	if (dv.charAt(0) != d1 || dv.charAt(1) != d2) { 
		return false; 
	} 
	return true; 
} 

function valida_CNPJ(cnpj) {
	var i; 
	
	cnpj = cnpj.replace(".", "");
	cnpj = cnpj.replace(".", "");
	cnpj = cnpj.replace("/", "");
	cnpj = cnpj.replace("-", "");
	
	var c = cnpj.substr(0,12);
	var dv = cnpj.substr(12,2);
	
	var d1 = 0;
	var ms = "543298765432";

	for (i = 0; i < 12; i++) { 
		d1 += c.charAt(i)*ms.charAt(i); 
	} 
	d1 = (d1 % 11); 
	if (d1 == 0 || d1 == 1) { 
		d1 = 0; 
	} 
	else { 
		d1 = 11 - d1; 
	}
	
	var d1 = 0;
	var ms = "543298765432";
	
	for (i = 0; i < 12; i++) {
		d1 += c.charAt(i)*ms.charAt(i);
	}
		d1 = (d1 % 11);
	if (d1 == 0 || d1 == 1) {
		d1 = 0;
	}
	else
	{
		d1 = 11 - d1;
	}
	
	var c = c + d1;
	var d2 = 0;
	var ms = "6543298765432";
	
	for (i = 0; i < 13; i++) {
		d2 += c.charAt(i)*ms.charAt(i);
	}
		d2 = (d2 % 11);
	if (d2 == 0 || d2 == 1) {
		d2 = 0;
	}
	else {
		d2 = 11 - d2;
	}
	if (dv.charAt(0) != d1 || dv.charAt(1) != d2) { 
		return false;
	} 
	return true;
} 

function valida_DATA(data_ano, data_mes, data_dia) {
	timeA = new Date(data_ano, data_mes, 1);
	timeD = timeA - 86400000;
	timeB = new Date(timeD);
	
	var daysInMonth = timeB.getDate();
	
	if (daysInMonth >= data_dia) {
		return true;
	}
	else {
		return false;
	}
}


// Funcao de alternancia de select's
// Criada por Pamela Cabezas
function posInicial() {
         selectNone = document.getElementById('formNone');
         selectArtigos = document.getElementById('formArt');
         selectJuris = document.getElementById('formJuris');
		 selectParecer = document.getElementById('formParecer');
         selectArtigos.style.display = 'none';
         selectJuris.style.display = 'none';
		 selectParecer.style.display = 'none';
}
function showSelect() {
	estado = document.getElementById('formFiltro').value;
	if(estado=='2') {
         selectJuris.style.display = 'none';
         selectNone.style.display = 'none';
		 selectParecer.style.display = 'none';
         selectArtigos.style.display = 'block';
         }
         else {
             if(estado == '1') {
             selectArtigos.style.display = 'none';
             selectNone.style.display = 'none';
			 selectParecer.style.display = 'none';
             selectJuris.style.display = 'block';}
             else {
			 	if(estado == '3') {
				selectJuris.style.display = 'none';
				selectArtigos.style.display = 'none';
				selectNone.style.display = 'none';				
				selectParecer.style.display = 'block';}
				else {
				selectParecer.style.display = 'none';
				selectJuris.style.display = 'none';
				selectArtigos.style.display = 'none';
				selectNone.style.display = 'block';}
             }
	
		}
}


function contratoLido(){
	
	coc = document.getElementById('cocordo');
	visi = document.getElementById('visitante');
	peri = document.getElementById('periodico');
	age = document.getElementById('agenda');
	out = document.getElementById('outros');
	promo1 = document.getElementById('promo1');

	if(!age.checked && !visi.checked && !peri.checked && !out.checked && !promo1.checked){
		alert('Favor, definir a sua relação conosco.');
		visi.focus();
		return false;
	}
		
	if(coc.checked==false){
		alert('Favor, ler e confirmar se está de acordo com nosso contrato.');
		coc.focus();
		return false;
	}

	return true;

}
function expandeBusca() {
	var dc = document.getElementById("dc").value;
	var cont = "<h3 class=\"ImageReplacement\">Busca Geral</h3><input class=\"formBusca\" type=\"text\" value=\"Digite sua busca\" name=\"busca\" onFocus=\"limpa(this)\" onBlur=\"preenche(this)\" title=\"Digite sua busca\" tabindex=\"30\" /> 				<input class=\"formOK\" type=\"image\" src=\"" + dc + "images/bgInputFormBuscaOK.gif\" tabindex=\"36\" title=\"Pressione enter para enviar ou tab para voltar a busca geral\" /> 				<div class=\"formFecha\"> 					<h4>Selecione a categoria</h4>                     <select class=\"formFiltro\" id=\"formFiltro\" name=\"classificacao\" onchange=\"showSelect()\" title=\"Escolha uma categoria e pressione enter para habilitar o filtro respectivo a esta categoria\" tabindex=\"31\"> 						<option value=\"\" selected>Busca Geral</option> 						<option value=\"1\">Jurisprud&ecirc;ncia</option> 						<option value=\"2\">Artigos</option> 						<option value=\"3\">Parecer</option> 						<option value=\"4\">Decis&atilde;o</option> 						<option value=\"5\">Senten&ccedil;a</option> 						<option value=\"6\">Pr&aacute;tica</option> 						<option value=\"7\">Legisla&ccedil;&atilde;o</option>                     </select> 					<h4>Selecione o filtro</h4> 					<select class=\"formFiltro\" id=\"formNone\" name=\"formNone\" value=\"\" title=\"Selecione um filtro para esta categoria\" tabindex=\"32\"> 						<option selected=\"selected\" disabled>Sem Filtro</option> 					</select> 					<select class=\"formFiltro\" id=\"formJuris\" name=\"filtro_juris\" title=\"Selecione um filtro para esta categoria\" tabindex=\"33\">                         <option value=\"1\">C&iacute;vel</option>                         <option value=\"2\">Criminal</option>                         <option value=\"3\">Trabalhista</option>                         <option value=\"4\">Comentada</option> 					</select> 					<select class=\"formFiltro\" id=\"formArt\" name=\"filtro_art\" title=\"Selecione um filtro para esta categoria\" tabindex=\"34\">                         <option value=\"5\">Administrativo</option>                         <option value=\"6\">Agr&aacute;rio</option>                         <option value=\"7\">Ambiental</option>                         <option value=\"8\">Civil</option>                         <option value=\"9\">Comercial</option>                         <option value=\"10\">Constitucional</option>                         <option value=\"11\">Crian&ccedil;a e Adolescente</option>                         <option value=\"12\">Fam&iacute;lia</option>                         <option value=\"13\">Trabalho</option>                         <option value=\"14\">Tr&acirc;nsito</option>                         <option value=\"15\">Eleitoral</option>                         <option value=\"16\">Militar</option>                         <option value=\"17\">Municipal</option>                         <option value=\"18\">Penal</option>                         <option value=\"19\">Processual Civil</option>                         <option value=\"20\">Processual Penal</option>                         <option value=\"21\">Tribut&aacute;rio</option>                         <option value=\"22\">Indeniza&ccedil;&atilde;o</option>                         <option value=\"23\">ResponsabilidaCivil</option> 						<option value=\"30\">Previdenci&aacute;rio</option> 						<option value=\"31\">Consumidor</option> 						<option value=\"32\">Inform&aacute;tica</option> 						<option value=\"33\">Imobili&aacute;rio</option> 					</select> 					<select class=\"formFiltro\" id=\"formParecer\" name=\"filtro_parec\" title=\"Selecione um filtro para esta categoria\" tabindex=\"35\">                         <option value=\"24\">Parecer</option>                         <option value=\"25\">Parecer do MP</option> 					</select> 					<div class=\"formReduz\"> 						<a class=\"ImageReplacement\" href=\"#\" title=\"Pressione aqui para reduzir a busca para busca geral\" tabindex=\"38\" onclick=\"reduzBusca()\" onkeypress=\"reduzBusca()\">Pesquisa geral</a> 					</div> 				</div>";
		document.getElementById("formTop").innerHTML = cont;
		posInicial();
}
function reduzBusca() {
	var dc = document.getElementById("dc").value;
	var cont = "<div class=\"formAbre\"><a class=\"ImageReplacement\" href=\"#\" title=\"Pressione aqui para ampliar a busca para busca avan&ccedil;ada de categorias\" tabindex=\"37\"  onclick=\"expandeBusca()\"  onkeypress=\"expandeBusca()\">Pesquisa avançada por categorias</a> 				</div> 				<h3 class=\"ImageReplacement\">Busca Geral</h3> 				<input class=\"formBusca\" type=\"text\" value=\"Digite sua busca\" name=\"busca\" onFocus=\"limpa(this)\" onBlur=\"preenche(this)\" title=\"Digite sua busca\" tabindex=\"30\" /> 				<input class=\"formOK\" type=\"image\" src=\"" + dc + "images/bgInputFormBuscaOK.gif\" tabindex=\"36\" title=\"Pressione enter para enviar ou tab para pesquisar por categoria\" />";
		document.getElementById("formTop").innerHTML = cont;

}
function continua(){
	document.getElementById('rolaNoticias').start();
}
