function removeProfissional(codigoProfissional) {
	if (confirm('Deseja realmente excluir este participante?'))
		xajax_exclui('profissional', codigoProfissional);
}

function validaEnvio(tipo) {
	
	var msg = '';
	if (tipo == 1) {
		if (document.getElementById('tipo_valor') != null) {
			if (document.getElementById('tipo_valor').value == 'equipe') {
				// VALIDAÇÃO CASO SEJA POR EQUIPE
			}
		}
		
		var i = 1;
		var contador = 0;
		for(i=1; i<6; i++) {
			if (document.getElementById('imagem'+i).value != '' || document.getElementById('img'+i) != null)
				contador++;
		}
		
		if (contador < 3) {
			msg += "* É preciso haver no mínimo 3 imagens. \n";
		}
		
		if (document.getElementById('nome').value == '') {
			msg += "* O nome do portifólio não pode ficar em branco. \n";
		}
		
		if (document.getElementById('descricao').value == '') {
			msg += "* O texto não pode ficar em branco. \n";
		}
		
		if ( document.getElementById('termos').checked == false )
			msg += "* Você deve estar de acordo com o termo de participação. \n";
		
		if (msg.length == 0) {
			if (confirm('Deseja realmente enviar este portifólio?'))
				document.form_portifolio.submit();
		}
		else {
			alert("Preencha as pendências encontradas: \n\n" + msg);
		}
	}
	
	document.getElementById('enviado').value = 0;	
	
	if (msg == "")
		document.getElementById('btEnvia').style.display = "none";
	/*
	if (tipo == 0) {
		document.getElementById('enviado').value = 0;
		
		if (confirm("Este porfolio ainda não foi enviado.\n Para enviá-lo deve clicar em enviar."))
			document.form_portifolio.submit();
	}
	*/
}

function limite(element, limite) {
    
    if (element.value.length > limite)
        element.value = element.value.substr(0, limite);
    
}

function imprimeFavoritos(idJurado){
    window.open('imprime_favoritos.php?idJurado='+idJurado,'popup','width=800,height=600,scrolling=auto,top=0,left=0');
}

function imprimeTrabalhos(){
    window.open('imprime_trabalhos.php', 'popup','width=800,height=600,scrolling=auto,top=0,left=0');
}

function exclui(tipo, id) {
    if (confirm('Deseja realmente excluir este registro?')) {
         xajax_exclui(tipo, id);
         
         setTimeout(window.location.reload(), 500);
    }
    
}

function enviarTrabalho(tipo) {
    if (confirm('Deseja realmente enviar os trabalhos selecionados?'))
        xajax_enviarTrabalho(tipo);
}

function marcacao(portifolio, checked, marcacao, desc, categoria) {
    if (checked) {
        if (confirm('Deseja realmente marcar o portifólio ' + desc + ' como favorito?')) {
             xajax_marcarFavorito(portifolio, checked, marcacao, categoria);
             document.getElementById("check" + portifolio).checked = true;
        }
        else {
            document.getElementById("check" + portifolio).checked = false;
        }
    }
    else {
        if (confirm('Deseja realmente retirar o portifólio ' + desc + ' de seus favoritos?')) {
             xajax_marcarFavorito(portifolio, checked, marcacao, categoria);
             document.getElementById("check" + portifolio).checked = false;
        }
        else {
             document.getElementById("check" + portifolio).checked = true;
        }
    } 
    
    
}

function logout() {
    if (confirm('Deseja realmente sair do sistema?')) {
        xajax_logout();
    }
}

function somenteNumero(e,txt) {
	var navegador = (navigator.appName == "Netscape") ? "NT" : "IE";
	var charCode = (navegador == "NT") ? e.which : e.keyCode;

	//alert(charCode);
	if (charCode != 13 && 
		charCode != 9 && 
		charCode != 0 && 
		charCode != 8 && 
	   (charCode  < 48 || charCode  > 57)) {
		if (navegador=="NT") {
			return e.preventDefault(); 
		} else {
			e.returnValue = false;
		}
	} else {
		if (txt.value.search(",") >= 0 && 
			charCode == 44 && 
			charCode == 46 && 
			charCode == 8) {
			if (navegador=="NT") {
				return e.preventDefault(); 
			} else {
				e.returnValue = false;
			}
		}
	}
}