var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"

function tiraEspaco(texto){
	while(texto.indexOf(" ") != -1){
	  texto = texto.replace(" ","");
	}
    return texto;
}
function montaPerguntasFrequentes(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando perguntas frequentes...</div>'
	enviaRequisicao('divConteudo','perguntasFrequentes.php',mensagem);
}

function montarFechamentoArquivo(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;width:315px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando fechamento de arquivo...</div>'
	enviaRequisicao('divConteudo','fechamentoArquivo.php',mensagem);
}

function montarRegulamento(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;width:315px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando regulamento...</div>'
	enviaRequisicao('divConteudo','regulamento.php',mensagem);
}
function montarInscricao(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;width:315px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando inscrição...</div>'
	enviaRequisicao('divConteudo','inscricao.php',mensagem);
}

function montaEsqueciSenha(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando esqueci minha senha...</div>'
	enviaRequisicao('divTelaNovoCadastro','inscricao.php',mensagem);
}

function montaInscricaoUsuario(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando cadastro...</div>'
	enviaRequisicao('divConteudo','inscricao/cadastro.php',mensagem);
}

function montaCadastroCompleto(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando cadastro...</div>'
	enviaRequisicao('divConteudo','inscricao/cadastro03.php',mensagem);
}

function cadastroInicialIncricao(id){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando cadastro realizado com sucesso...</div>'
	enviaRequisicao('divConteudo','inscricao/cadastro02.php?id='+id,mensagem);
}

function montaAlterarCadastro(id){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando meus dados...</div>'
	enviaRequisicao('divConteudo','inscricao/cadastro03.php?id='+id,mensagem);
}

function montaInscricaoObras(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando cadastro...</div>'
	enviaRequisicao('divConteudo','inscricao/cadastro_obra.php',mensagem);
}

function gerarPdf(id){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando cadastro...</div>'
	enviaRequisicao('divConteudo','inscricao/geradorPdf.php?obras='+id,mensagem);
}
function cadastroObras(id){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Gerando comprovante...</div>'
	enviaRequisicao('divConteudo','inscricao/cadastro_obra02.php?obras='+id,mensagem);
	//document.getElementById('divConteudo').innerHTML = '<table width="315" cellpadding="0" cellspacing="0" border="0"><tr><td class="titulo_grande" colspan="2">.novo trabalho</td></tr><tr><td height="10"></td></tr><tr><td width="280" valign="top"><div id="divTelaUsuarioInscricao"><table cellpadding="0" cellspacing="0" border="0" width="280"><tr><td class="titulo" colspan="3">cadastro realizado com sucesso.</td></tr><tr><td height="10" colspan="3"></td></tr><tr><td height="10" colspan="3"><div align="left" style="cursor:pointer" onclick="javascript:realizarLogin()">clique aqui para o cadastro de seu trabalho</div></td></tr></table>';		
}

function alteraObra(id){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando cadastro...</div>'
	enviaRequisicao('divConteudo','inscricao/cadastro_obra.php?obras='+id,mensagem);
	return nd();
}
function menuFinalizarObra(id){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando cadastro...</div>'
	alert("Verifique as informaçoes do trabalho e clique em finalizar");
	enviaRequisicao('divConteudo','inscricao/cadastro_obra.php?obras='+id,mensagem);
	return nd();
}

function submit(){
	if(document.getElementById('nome').value == ""){
		document.getElementById('nome').focus();
		alert("Informe o Nome.");
		return true;
	}	
	if(document.getElementById('email').value == ""){
		document.getElementById('email').focus();
		alert("Informe o E-mail.");
		return true;		
	}else{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("email").value))){ 
			alert("Precisa ser um e-mail válido.");
			document.getElementById("email").focus();
			return;
	    } 
	}
	if(document.getElementById('pergunta').value == ""){
		document.getElementById('pergunta').focus();
		alert("Informe a pergunta.");
		return true;		
	}
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Cadastrando...</div>';
	campos = 'nome='+document.getElementById('nome').value+'&email='+document.getElementById('email').value+'&pergunta='+document.getElementById('pergunta').value;
	enviarForm('perguntasFrequentes01.php', campos, 'divFormularioPerguntas', mensagem);
}

function submitInscricao(){
	if(document.getElementById('login').value == ""){
		document.getElementById('login').focus();
		alert("Informe o Login.");
		return false;		
	}else{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("login").value))){ 
			alert("O login precisa ser um e-mail válido.");
			document.getElementById("login").focus();
			return false;	
	    } 
	}
	if(document.getElementById('senha').value == ""){
		document.getElementById('senha').focus();
		alert("Informe a senha.");
		return false;	
	}
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Verificando dados...</div>';
	campos = 'login='+document.getElementById('login').value+'&senha='+document.getElementById('senha').value;
	enviarForm('loginResults.php', campos, 'divTelaUsuarioInscricao', mensagem);
	return false;	
}

function submitInicioCadastro(){
	if(document.getElementById('login').value == ""){
		document.getElementById('login').focus();
		alert("Informe o login.");
		return false;		
	}else{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("login").value))){ 
			alert("informe um e-mail válido.");
			document.getElementById("login").focus();
			return false;		
	    } 
	}
	if(document.getElementById('senha').value == ""){
		document.getElementById('senha').focus();
		alert("Informe a senha.");
		return false;			
	}
	if(document.getElementById('confirmaSenha').value == ""){
		document.getElementById('confirmaSenha').focus();
		alert("Informe a confirmação de senha.");
		return false;			
	}
	if(document.getElementById('senha').value != document.getElementById('confirmaSenha').value){
		document.getElementById('confirmaSenha').focus();
		alert("Confirmação de senha diferente da senha.");
		return false;				
	}

	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Cadastrando...</div>';
	campos = 'login='+document.getElementById('login').value+'&senha='+document.getElementById('senha').value;
	enviarForm('inscricao/cadastro01.php', campos, 'divConteudo', mensagem);
	return false;		
}

function submitCadastroCompleto(){
	campos = "";
	if(tiraEspaco(document.getElementById('nome').value) == ""){
		document.getElementById('nome').focus();
		alert("Informe o nome.");
		return true;		
	}
	if(tiraEspaco(document.getElementById('cpf').value) == ""){	
		alert("Informe o CPF.");
		document.getElementById('cpf').focus();
		return;
	}else{
		if (!verificaCPF(document.getElementById('cpf').value)){
			alert("CPF inválido.");
			document.getElementById('cpf').focus();
			return false;
		}
	}	
		
	if(tiraEspaco(document.getElementById('identidade').value) == ""){
		document.getElementById('identidade').focus();
		alert("Informe a identidade.");
		return true;		
	}
	if(tiraEspaco(document.getElementById('profissao').value) == ""){
		document.getElementById('profissao').focus();
		alert("Informe a profissão.");
		return true;		
	}
	if(document.getElementById('dtNascimento').value == ""){
		document.getElementById('dtNascimento').focus();
		alert("Informe a data de nascimento.");
		return true;		
	}
	if(tiraEspaco(document.getElementById('endereco').value) == ""){
		document.getElementById('endereco').focus();
		alert("Informe o endereco.");
		return true;		
	}
	if(tiraEspaco(document.getElementById('bairro').value) == ""){
		document.getElementById('bairro').focus();
		alert("Informe o bairro.");
		return true;		
	}
	if(tiraEspaco(document.getElementById('cidade').value) == ""){
		document.getElementById('cidade').focus();
		alert("Informe a cidade.");
		return true;		
	}
	if(document.getElementById('estado_id').value == 0){
		document.getElementById('estado_id').focus();
		alert("Informe o estado.");
		return true;		
	}
	if(tiraEspaco(document.getElementById('cep').value) == ""){
		document.getElementById('cep').focus();
		alert("Informe o cep.");
		return true;		
	}
	if(tiraEspaco(document.getElementById('pais').value) == ""){
		document.getElementById('pais').focus();
		alert("Informe o país.");
		return true;		
	}
	if(tiraEspaco(document.getElementById('telefone').value) == ""){
		document.getElementById('telefone').focus();
		alert("Informe o telefone.");
		return true;		
	}
	if(document.getElementById('altera').value != 0){
		alteraCampos = "altera=" + document.getElementById('altera').value + "&";
	}else{
		alteraCampos = "";
	}
	
	setarCamposSubmeterCadastroCompleto();
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Cadastrando...</div>';
	campos = alteraCampos + campos;
	enviarForm('inscricao/cadastro04.php', campos, 'divConteudo', mensagem);
}
function setarCamposSubmeterCadastroCompleto(){
	campos = "usuarioId="+encodeURI(document.getElementById('usuarioId').value);
	campos +="&nome="+encodeURI(document.getElementById('nome').value);
	campos +="&cpf="+encodeURI(document.getElementById('cpf').value);
	campos +="&identidade="+encodeURI(document.getElementById('identidade').value);
	campos +="&profissao="+encodeURI(document.getElementById('profissao').value);
	campos +="&dtNascimento="+encodeURI(document.getElementById('dtNascimento').value);
	campos +="&endereco="+encodeURI(document.getElementById('endereco').value);
	campos +="&cidade="+encodeURI(document.getElementById('cidade').value);
	campos +="&estado_id="+encodeURI(document.getElementById('estado_id').value);
	campos +="&bairro="+encodeURI(document.getElementById('bairro').value);
	campos +="&pais="+encodeURI(document.getElementById('pais').value);
	campos +="&cep="+encodeURI(document.getElementById('cep').value);
	campos +="&telefone="+encodeURI(document.getElementById('telefone').value);
	campos +="&celular="+encodeURI(document.getElementById('celular').value);
}

function submitEsqueciMinhaSenha(){
	if(document.getElementById('esqueciEmail').value == ""){
		document.getElementById('esqueciEmail').focus();
		alert("Informe o e-mail.");
		return true;		
	}else{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("esqueciEmail").value))){ 
			alert("informe um e-mail válido.");
			document.getElementById("esqueciEmail").focus();
			return;
	    } 
	}

	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Enviando e-mail...</div>';
	campos = 'esqueciEmail='+document.getElementById('esqueciEmail').value;
	enviarForm('esqueciMinhaSenha.php', campos, 'divEsqueciMinhaSenha', mensagem);
}

function submitCadastroObra(){
	var strValues = "";
	var boxLength = document.getElementById('destList').length;
	var count = 0;
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			if (count == 0) {
				strValues = document.getElementById('destList').options[i].value;
			}else {
				strValues = strValues + ";" + document.getElementById('destList').options[i].value;
			}
			count++;
	   }
	}
	
	var tec_outraTemp="";
	if(document.getElementById('tecnica').value == "999"){
		if(tiraEspaco(document.getElementById('tec_outra').value) == ""){
			document.getElementById('tec_outra').focus();
			alert("Informe a descrição da técnica.");
			return false;		
		}
		var tec_outraTemp=encodeURI(document.getElementById('tec_outra').value);
	}
	
	if(tiraEspaco(document.getElementById('autor').value) != ""){
		document.getElementById('autor').focus();
		alert('clique em "adicionar" para adicionar mais autores.');
		return false;		
	}
	
	setarCamposSubmeterCadastroObra();
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Cadastrando...</div>';
	campos = 'finalizar=0&coAutores='+encodeURI(strValues)+'&tec_outra='+tec_outraTemp+'&altera='+document.getElementById('altera').value+campos;
	enviarForm('inscricao/cadastro_obra01.php', campos, 'divConteudo', mensagem);
	return false;
}
function finalizarCadastroObra(){
//pega os links relacionados
	var strValues = "";
	var boxLength = document.getElementById('destList').length;
	var count = 0;
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			if (count == 0) {
				strValues = document.getElementById('destList').options[i].value;
			}else {
				strValues = strValues + ";" + document.getElementById('destList').options[i].value;
			}
			count++;
	   }
	}
	
	if(tiraEspaco(strValues) == ""){
		document.getElementById('autor').focus();
		alert("Informe pelo menos um ator para o trabalho. \n Não é permitido o cadastro sem autor(es).");
		return false;			
	}
	/*if(tiraEspaco(document.getElementById('nome').value) == ""){
		document.getElementById('nome').focus();
		alert("Informe o Autor.");
		return false;		
	}*/
	if(tiraEspaco(document.getElementById('autor').value) != ""){
		document.getElementById('autor').focus();
		alert('clique em "adicionar" para adicionar mais autores.');
		return false;		
	}
	if(tiraEspaco(document.getElementById('titulo').value) == ""){
		document.getElementById('titulo').focus();
		alert("Informe o título.");
		return false;		
	}
	if(document.getElementById('tecnica').value == "0"){
		document.getElementById('tecnica').focus();
		alert("Informe o técnica.");
		return false;		
	}
	var tec_outraTemp="";
	if(document.getElementById('tecnica').value == "999"){
		if(tiraEspaco(document.getElementById('tec_outra').value) == ""){
			document.getElementById('tec_outra').focus();
			alert("Informe a descrição da técnica técnica.");
			return false;		
		}
		var tec_outraTemp=encodeURI(document.getElementById('tec_outra').value);
	}
	if(tiraEspaco(document.getElementById('n_pagina').value) == ""){
		document.getElementById('n_pagina').focus();
		alert("Informe o número de página.");
		return false;		
	}
	if(tiraEspaco(document.getElementById('sobreObra').value) == ""){
		document.getElementById('sobreObra').focus();
		alert("Informe sobre o trabalho.");
		return false;		
	}
	if(document.getElementById('condicoes').checked==false){
		alert("Você deve aceitar as condições do regulamento para poder finalizar.");
		return false;		
	}
	if (confirm("Tem certeza que deseja finalizar?\nUma vez finalizada, você não poderá alterar a inscrição")){
		setarCamposSubmeterCadastroObra();
		mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Cadastrando...</div>';
		campos = 'finalizar=1&coAutores='+encodeURI(strValues)+'&tec_outra='+tec_outraTemp+'&altera='+document.getElementById('altera').value+campos;
		enviarForm('inscricao/cadastro_obra01.php', campos, 'divConteudo', mensagem);
		return false;
	}
}
function setarCamposSubmeterCadastroObra(){
	campos = "&obrasId="+encodeURI(document.getElementById('obrasId').value);
	campos +="&autor="+encodeURI(document.getElementById('nome').value);
	campos +="&titulo="+encodeURI(document.getElementById('titulo').value);
	campos +="&tecnica="+encodeURI(document.getElementById('tecnica').value);
	campos +="&n_pagina="+encodeURI(document.getElementById('n_pagina').value);
	campos +="&sobreObra="+encodeURI(document.getElementById('sobreObra').value);
}

function submitContato(){
	if(document.getElementById('nome').value == ""){
		document.getElementById('nome').focus();
		alert("Informe o Nome.");
		return true;
	}	
	if(document.getElementById('email').value == ""){
		document.getElementById('email').focus();
		alert("Informe o E-mail.");
		return true;		
	}else{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("email").value))){ 
			alert("Precisa ser um e-mail válido.");
			document.getElementById("email").focus();
			return;
	    } 
	}
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Cadastrando...</div>';
	campos = 'nome='+document.getElementById('nome').value+'&email='+document.getElementById('email').value+'&msn='+document.getElementById('msn').value;
	enviarForm('contato01.php', campos, 'divFormularioContato', mensagem);	
}

function realizarLogin(){
	document.getElementById('divTelaUsuarioInscricao').innerHTML ='Logando...';	

	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Carregando página...</div>';
	enviaRequisicao('divTelaUsuarioInscricao','inscricao/menuOpcoes.php',mensagem);
	chamaBarra();
}

function mostrarErro(qualErro){
	document.getElementById('divFormularioPerguntas').innerHTML = '<table width="100%" border="0"><tr><td colspan="2" class="titulo_grande">.tire sua dúvida, faça sua pergunta</td></tr><tr><td colspan="2" height="5"></td></tr><tr><td width="50" align="left" colspan="2"><b>ERROS: ' + qualErro + '</b></td></tr></table>';	
}

function mostrarErroLogin(qualErro){
	document.getElementById('divTelaUsuarioInscricao').innerHTML = '<table cellpadding="0" cellspacing="0" border="0" width="270"><tr><td class="titulo" colspan="3">' + qualErro + '</td></tr><tr><td><div align="center" style="cursor:pointer" onclick="javascript:montarInscricao()">Clique aqui para voltar para o formulário.</div></table>';	
}

function mostrarCadastroRealizado(){
	document.getElementById('divFormularioPerguntas').innerHTML = '<table width="100%" border="0"><tr><td colspan="2" class="titulo_grande">.pergunta realizada com sucesso</td></tr><tr><td colspan="2" height="5"></td></tr><tr><td align="left" colspan="2"><br>Em breve responderemos sua pergunta por e-mail.<br><br><div onclick="mostrarVoltaCadastroRealizado()" class="botaoGrande">&nbsp;clique aqui para fazer outra pergunta</div></td></tr></table>';	
}
function mostrarContatoRealizado(){
	document.getElementById('divFormularioContato').innerHTML = '<table width="100%" border="0"><tr><td colspan="2" class="titulo_grande">.contato</td></tr><tr><td colspan="2" height="5"></td></tr><tr><td align="left" colspan="2"><br>Mensagem enviada com sucesso.<br><br></table>';	
}

function mostrarVoltaCadastroRealizado(){
	//document.getElementById('divFormularioPerguntas').innerHTML = '<table width="100%" border="0"><tr><td colspan="2" class="titulo_grande">.tire sua dúvida, faça sua pergunta</td></tr><tr><td colspan="2" height="5"></td></tr><tr><td width="50" align="right">Nome:</td><td><input type="text" size="44" id="nome" name="nome"></td></tr><tr><td colspan="2" height="5"></td></tr><tr><td width="50" align="right">E-mail:</td><td><input type="text" size="44" id="email" name="email"></td></tr><tr><td colspan="2" height="5"></td></tr><tr><td width="50" align="right" valign="top">Pergunta:</td><td><textarea id="pergunta" name="pergunta" rows="2" cols="42" style="width:228px;"></textarea></td></tr><tr><td colspan="2" height="3"></td></tr><tr><td align="right" colspan="2"><div style="float:left"><b>*Todos os campos são obrigatórios</b>&nbsp;</div><div align="center" class="botao" onclick="javascript:submit()">Enviar</div></td></tr></table>';	
	montaPerguntasFrequentes();		
}

function montaEsqueciSenha(){
	document.getElementById('divEsqueciMinhaSenha').innerHTML = '<table width="90%" border="0"><tr><td colspan="2" class="titulo_grande">.esqueci minha senha</td></tr><tr><td colspan="2" height="5"></td></tr><tr><td colspan="2">e-mail<td></tr><tr><td><input type="text" size="35" id="esqueciEmail" name="esqueciEmail"></td><td><div align="center" class="botao" onclick="javascript:submitEsqueciMinhaSenha()">enviar</div></td></tr><tr><td height="10" colspan="2"></td></tr></table>';	
}

function mostrarErroEsqueciMinhaSenha(erroEncontrado){
	document.getElementById('divEsqueciMinhaSenha').innerHTML = '<table width="100%" border="0"><tr><td colspan="2" class="titulo_grande">.esqueci minha senha</td></tr><tr><td colspan="2" height="5"></td></tr><tr><td height="10" colspan="3" class="vermelho">' + erroEncontrado + '<td></tr><tr><td height="10" colspan="3"></td></tr></table>';		
	alert(erroEncontrado);
}

function mostrarSucessoEsqueciMinhaSenha(texto){
	document.getElementById('divEsqueciMinhaSenha').innerHTML = '<table width="100%" border="0"><tr><td colspan="2" class="titulo_grande">.esqueci minha senha</td></tr><tr><td colspan="2" height="5"></td></tr><tr><td height="10" colspan="3">' + texto + '<br><br><td></tr><tr><td height="10" colspan="3"></td></tr></table>';		
	alert(texto);
}
function usuarioExistente(){
	document.getElementById('divConteudo').innerHTML = '<table width="100%" border="0"><tr><td colspan="2" class="titulo_grande">.novo cadastro</td></tr><tr><td colspan="2" height="5"></td></tr><tr><td height="10" colspan="3" class="vermelho">E-mail já cadastrado<td></tr><tr><td height="10" colspan="3"></td></tr><tr><td height="10" colspan="3"><div align="left" style="cursor:pointer" onclick="javascript:montaInscricaoUsuario()"><b>clique aqui para realizar outro cadastro</b></div></td></tr></table>';		
	alert("E-mail já cadastrado");
}
function cadastroCompletoRealizado(id){
	if(id == 0){
		enviaRequisicao('divConteudo','inscricao/cadastro_obra.php','carregando...');
		//document.getElementById('divConteudo').innerHTML = '<table width="100%" border="0"><tr><td colspan="2" class="titulo_grande">.novo cadastro</td></tr><tr><td colspan="2" height="5"></td></tr><tr><td height="10" colspan="3">cadastro realizado com sucesso.<td></tr><tr><td height="10" colspan="3"></td></tr><tr><td height="10" colspan="3"><div align="left" style="cursor:pointer" onclick="javascript:montaInscricaoObras()"><b>clique aqui para cadastrar de seu trabalho</b></div></td></tr></table>';		
	}else{
		document.getElementById('divConteudo').innerHTML = '<table width="100%" border="0"><tr><td colspan="2" class="titulo_grande">.alteração de cadastro</td></tr><tr><td colspan="2" height="5"></td></tr><tr><td height="10" colspan="3">alteração realizada com sucesso.<td></tr><tr><td height="10" colspan="3"></td></tr><tr><td height="10" colspan="3"><div align="center" class="botaoVoltar" onclick="javascript:voltarMenuOpcoes()"><b>voltar</b></div></td></tr></table>';		
	}	
}

function voltarMenuOpcoes(){
	document.getElementById('divConteudo').innerHTML = '<table width="315" cellpadding="0" cellspacing="0" border="0"><tr><td class="titulo_grande" colspan="2">.minhas inscrições</td></tr><tr><td height="10"></td></tr><tr><td width="280" valign="top"><div id="divTelaUsuarioInscricao"><table cellpadding="0" cellspacing="0" border="0" width="280"><tr><td class="titulo" colspan="3"></td></tr><tr><td height="10" colspan="3"></td></tr><tr><td height="10" colspan="3"></td></tr></table>';
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Carregando página...</div>';
	enviaRequisicao('divTelaUsuarioInscricao','inscricao/menuOpcoes.php',mensagem);
}

function chamaBoca01(){
	chamaSiteAntigo();
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>';
	enviaRequisicao('divConteudo','boca01.php',mensagem);
}

function chamaSiteAntigo(){
	window.open("http://issuu.com/revistaboca/docs/boca1","revistaboca");
}

function chamaNoticias(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Carregando notícias...</div>';
	enviaRequisicao('divConteudo','noticias.php',mensagem);
}

function chamaMaisNoticias(pagina){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>';
	enviaRequisicao('divMontaPaginaNoticia','maisNoticia.php?pagina='+pagina,mensagem);
}

function chamaImprensa(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Carregando imprensa...</div>';
	enviaRequisicao('divConteudo','impresa.php',mensagem);
}

function downloadArquivo(arquivo){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	window.open("http://revistaboca.org/download.php?arquivoSelecionado="+arquivo,"revistaboca","height=0,width=0,left=500,top=430,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no");
}

function chamaContato(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Carregando contato...</div>';
	enviaRequisicao('divConteudo','contato.php',mensagem);
}

function chamaHome(){
	mensagem = 'home...';
	limpaImagemLinhas();
	enviaRequisicao('divConteudo','noticias.php',mensagem);
}

function chamaImagem(){
	document.getElementById('divImagem').innerHTML = "<img src='img/barra_linhas.gif'>";
	document.getElementById('divConteudo').innerHTML = "<br><br><br><br><br><br><br><br><img src='img/img_boca_convida_home.gif'>";
}

function chamaBarra(){
	enviaRequisicao2('divBarraTituloUsuario','barraUsuario.php','carregando...');
}

function chamaSair(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>fazendo o logoff do sistema...</div>'
	enviaRequisicao('divConteudo','sair.php',mensagem);	
}

function chamaHomeSaidaRealizada(){
	document.getElementById('divBarraTituloUsuario').innerHTML = '';
	enviaRequisicao('divConteudo','inscricao.php',mensagem);
}

function chamaUsuarioLogado(){
	document.getElementById('divConteudo').innerHTML = '<table width="315" cellpadding="0" cellspacing="0" border="0"><tr><td class="titulo_grande" colspan="2">.inscrição</td></tr><tr><td height="10"></td></tr><tr><td width="280" valign="top"><div id="divTelaUsuarioInscricao"><table cellpadding="0" cellspacing="0" border="0" width="280"><tr><td class="titulo" colspan="3"></td></tr><tr><td height="10" colspan="3"></td></tr><tr><td height="10" colspan="3"></td></tr></table>';
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;width:220px;float:center"><br><br><img src=img/loading_bm.gif border=0><br>Carregando página...</div>';
	enviaRequisicao('divTelaUsuarioInscricao','inscricao/menuOpcoes.php',mensagem);
	if(document.getElementById('divBarraOk') == null){
		chamaBarra();		
	}
}

function limpaImagemLinhas(){
	document.getElementById('divImagem').innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}

function excluirObras(id){
	mensagem = '';
	if (confirm("Tem certeza que deseja excluir esse trabalho?")){
		enviaRequisicao('divConteudo','inscricao/excluirObras.php?id='+id,mensagem);
		return nd();
	}
	return nd();	
}

//----------------------------------- função para scroll ----------------------------------------------
var speed = 10;
var contentheightRegulamento=1250;
var contentheightPerguntas=1170;
var contentheightComprovanteObras=220;
var contentheightFechamento=1400;
var moveupvar;
var movedownvar;
function mDownRegulamento(){
	var crossobj = document.getElementById? document.getElementById("contentM"):document.all.contentM;	
	valor = crossobj.style.top;
	valor = valor.replace("p","");
	valor = valor.replace("x","");
	valor = valor.replace("t","");
	if(parseInt(valor)>=(contentheightRegulamento*(-1)+100))
		crossobj.style.top= parseInt(valor)-speed + "px";
	movedownvar=setTimeout("mDownRegulamento()",100);

}
function mDownComprovanteObras(){
	var crossobj = document.getElementById? document.getElementById("contentM"):document.all.contentM;	
	valor = crossobj.style.top;
	valor = valor.replace("p","");
	valor = valor.replace("x","");
	valor = valor.replace("t","");
	if(parseInt(valor)>=(contentheightComprovanteObras*(-1)+100))
		crossobj.style.top= parseInt(valor)-speed + "px";
	movedownvar=setTimeout("mDownComprovanteObras()",100);

}
function mDownPerguntas(){
	var crossobj = document.getElementById? document.getElementById("contentM"):document.all.contentM;	
	valor = crossobj.style.top;
	valor = valor.replace("p","");
	valor = valor.replace("x","");
	valor = valor.replace("t","");
	if(parseInt(valor)>=(contentheightPerguntas*(-1)+100))
		crossobj.style.top= parseInt(valor)-speed + "px";
	movedownvar=setTimeout("mDownPerguntas()",100);

}
function mDownFechamento(){
	var crossobj = document.getElementById? document.getElementById("contentM"):document.all.contentM;	
	valor = crossobj.style.top;
	valor = valor.replace("p","");
	valor = valor.replace("x","");
	valor = valor.replace("t","");
	if(parseInt(valor)>=(contentheightFechamento*(-1)+100))
		crossobj.style.top= parseInt(valor)-speed + "px";
	movedownvar=setTimeout("mDownFechamento()",100);

}
function mUp(){
	var crossobj = document.getElementById? document.getElementById("contentM"):document.all.contentM;
	valor = crossobj.style.top;
	valor = valor.replace("p","");
	valor = valor.replace("x","");
	valor = valor.replace("t","");
	if(parseInt(valor)<=0)
		crossobj.style.top=parseInt(valor)+speed + "px";
	moveupvar=setTimeout("mUp()",100);
}

//----------------------------------- função para CPF ----------------------------------------------
function FormataCpf(campo,tammax,teclapres){
	var tecla = teclapres.keyCode;
	vr = campo.value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 3 ){ 
	 		campo.value = vr ; }
	 	if ( (tam > 3) && (tam <= 6) ){
	 		campo.value = vr.substr(0,3) + '.' + vr.substr(3, tam ) ; }
	 	if ( (tam > 6) && (tam <= 9) ){
	 		campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam) ; }
	 	if (tam > 9){
	 		campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam ) ; }
	}		
}	

function verificaCPF(campo){

	vr = campo;
	while (vr.indexOf(".")!=-1){
		   vr=vr.replace(".","");
	}
	while (vr.indexOf("-")!=-1){
		   vr=vr.replace("-","");
	}
  
	var i; 
	s = vr; 
	var c = s.substr(0,9); 
	var dv = s.substr(9,2); 
	var d1 = 0; 
  
	for (i = 0; i < 9; i++) { 
		d1 += c.charAt(i)*(10-i); 
	} 
	if (d1 == 0){ 
		return false; 
	}  
	d1 = 11 - (d1 % 11); 
	if (d1 > 9) d1 = 0; 
	if (dv.charAt(0) != d1) return false; 
	d1 *= 2; 
	for (i = 0; i < 9; i++) { 
		d1 += c.charAt(i)*(11-i); 
	} 
	d1 = 11 - (d1 % 11); 
	if (d1 > 9) d1 = 0; 
	if (dv.charAt(1) != d1) return false; 
	return true; 
} 

//----------------------------------- função para data ----------------------------------------------
function mascaraData(numero){
	var data = document.getElementById('dtNascimento').value;
	while (data.indexOf("/")!=-1){
		   data=data.replace("/","");
	}
	//alert(numero.keyCode);
	if ((numero.keyCode >= 35 && numero.keyCode <= 40) || (numero.keyCode == 46) ||
		(numero.keyCode == 8) || (numero.keyCode == 13) || (numero.keyCode == 9) ||
		(numero.keyCode >= 48 && numero.keyCode <= 57) || (numero.keyCode >= 96 && numero.keyCode <= 105)){
		if ((numero.keyCode != 8)&&(numero.keyCode != 46)){
			if (data.length == 2){
				data = data + '/'; 
				document.getElementById('dtNascimento').value = data;
				return true;
			}
			if (data.length == 4){ 
				data = data.substr(0,2) + "/" + data.substr(2,2) + "/"; 
				document.getElementById('dtNascimento').value = data; 
				return true;
			}
		}
	}else{
		return true;
	}
	
}

function sonumeros(numero1){
	//verifica o enter (13), o delete (46), o backspace (8), o end (35), o home (36) e as setas (37,38,39,40)
	if ((numero1.keyCode >= 35 && numero1.keyCode <= 40) || (numero1.keyCode == 46) ||
		(numero1.keyCode == 8) || (numero1.keyCode == 13) || (numero1.keyCode == 9) ||
		(numero1.keyCode >= 48 && numero1.keyCode <= 57) || (numero1.keyCode >= 96 && numero1.keyCode <= 105)){
		return true;
	}else{
		return false;
	}
}
	
function formataCep(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = campo.value;
	while (vr.indexOf("-")!=-1){
		   vr=vr.replace("-","");
	}
	tam = vr.length;
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
	if (tecla == 8 ){	tam = tam - 1 ; }
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 5 ){ 
 			campo.value = vr ; }
	 	if (tam > 5){
	 		campo.value = vr.substr(0,5) + "-" + vr.substr(5,3); 
	 	}
	}		
}

function mascaraTelefone(objeto){ 
   if(objeto.value.length == 0)
     objeto.value = '(' + objeto.value;

   if(objeto.value.length == 3)
      objeto.value = objeto.value + ') ';

 if(objeto.value.length == 9)
     objeto.value = objeto.value + '-';
}
function verificaTipoTecnica(){
	if(document.getElementById('tecnica').value == 999){
		//document.getElementById('tecnica').style.width="190px";
	    if (ie||w3){
	    	document.getElementById('tec_outra').style.display="block";
	    	document.getElementById('descTecnica').style.display="block";
	    	document.getElementById('tec_outra').style.visibility="visible";
	    	document.getElementById('descTecnica').style.visibility="visible";
	    }else{
	        document.getElementById('tec_outra').style.visibility ="show";
	        document.getElementById('descTecnica').style.visibility ="show";
	    }
	}else{
		//document.getElementById('tecnica').style.width='190px';		
		document.getElementById('tec_outra').style.display='none';
		document.getElementById('descTecnica').style.display='none';
	}
}

function addSrcToDestList() {
	if (document.getElementById('autor').value == ""){
		alert("Informe o autor para adicioná-lo.");
		return false;
	}
	destListTemp = document.getElementById('destList');
	var len = destListTemp.length;
	var found = false;
	for(var count = 0; count < len; count++) {
		if (destListTemp.options[count] != null) {
			if (document.getElementById('autor').value == destListTemp.options[count].value) {
				found = true;
				break;
		    }
	    }
	}
	if (found != true) {
		valor_campo = document.getElementById('autor').value;
		texto_para_aparecer = document.getElementById('autor').value;
		destListTemp.options[len] = new Option(texto_para_aparecer, valor_campo,false,false); 
		len++;
     }
     document.getElementById('autor').value = '';
     document.getElementById('autor').focus();
}
function deleteFromDestList() {
	var destListTemp  = document.getElementById('destList');
	var len = destListTemp.options.length;
	for(var i = (len-1); i >= 0; i--) {
		if ((destListTemp.options[i] != null) && (destListTemp.options[i].selected == true)) {
			destListTemp.options[i] = null;
	    }
   }
}

// Deletes the selected items of supplied list.
function deleteSelectedItemsFromList(sourceList) {
	var maxCnt = sourceList.options.length;
	for(var i = maxCnt - 1; i >= 0; i--) {
		if ((sourceList.options[i] != null) && (sourceList.options[i].selected == true)) {
			sourceList.options[i] = null;
	    }
   }
}

function textCounter(field, countfield, maxlimit) {
	campo = eval('document.getElementById("'+field+'")') ;
	tamCampo = eval('document.getElementById("'+countfield+'")') ;
	if (campo.value.length > maxlimit){ 
		campo.value = campo.value.substring(0, maxlimit);
	}else{ 
		tamCampo.value = maxlimit - campo.value.length;
		document.getElementById('contadorCaixaTexto').innerHTML = tamCampo.value;
	}	
}
