function CheckLen(Target) {
	StrLen = Target.value.length;

	maxLeght = 2000

	if (StrLen > maxLeght ) {
		Target.value = Target.value.substring(0,( maxLeght-1 ));
		CharsLeft = 0;
	}
	else {
		CharsLeft = maxLeght - StrLen;
	}
	//document.form_cad_trab.CharsLeft.value = CharsLeft;
	document.getElementById('contadorCarac').innerHTML = "Restam <B>" + CharsLeft + "</b> caracteres.";
}

function abreFechaDiv(div){
	if(document.getElementById(div).style.display == 'block')
		document.getElementById(div).style.display = 'none';
	else
		document.getElementById(div).style.display = 'block';
}

function divsEcamesc(div){
	document.getElementById('membros').style.display = 'none';
	document.getElementById('dicas').style.display = 'none';
	document.getElementById('inscricao_pessoa').style.display = 'none';
	document.getElementById('inscricao_trabalho').style.display = 'none';
	document.getElementById(div).style.display = 'block';
}

function validaCamposCurriculo(){
	with(document.formInicio) {	
	        if (nome.value == "" || email.value == "" || end.value == "" || cep.value == "" || cel.value == "" || dn.value == "" || mn.value == "" || an.value == "" || cpf.value == "" || instituicao.value == "" || ano_conclusao.value == ""){
			alert("Preencha os campos obrigatórios!");
			nome.focus();
			return false; }
			
			if(!ValidaEmail(email.value)){
			alert('Email inválido');
			email.focus();
			return false;
			}
			
    submit();
	}
	
}

function ValidaEmail(txt)
{  
  if ((txt.length < 6) || (txt.indexOf("@") < 1) || (txt.indexOf('.') <= 4))
     return false;	
  else
  	 return true;
}

function Tecla(e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		if (tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else
			{
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
}

function verificaFormCadEc(){
	var form = document.form_cad_ec;
	
	if(form.nome.value == '' || form.email.value == '' || form.ddd.value == '' || form.telefone.value == '' || form.email.value == ''  || form.profissao.value == ''  || form.curso.value == ''){
		alert("Preencha todos os campos obrigatorios");
		return;
	}
	
	if(!ValidaEmail(form.email.value)){
		alert("O email digitado não é um email válido!");
		return;
	}
	
	if(form.telefone.value.length < 7){
		alert("O telefone digitado não é válido!");
		return;
	}
	
	form.submit();
	
	form.nome.value = ''
	form.email.value = ''
	form.ddd.value = ''
	form.telefone.value = ''
	form.email.value = ''
	form.profissao.value = ''
	form.curso.value = ''
	
	
	
}

function verificaFormCadEcTrab(){
	var form = document.form_cad_trab;
	
	if(form.seunome.value == '' || (form.autor1.value == '' && form.autor2.value == '' && form.autor3.value == '' && form.autor4.value == '')  
	   || form.apresentador.value == '' || form.resumo.value == ''  ){
		alert("Preencha todos os campos obrigatorios");
		return;
	}
	
	form.submit();
	
	form.seunomev.value = ''
	form.autor1v.value = ''
	form.autor2v.value = ''
	form.autor3v.value = ''
	form.autor3.value = ''
	form.autor4v.value = ''
	form.orientadorv.value = ''
	form.apresentadorv.value = ''
	form.da.value = ''
	form.ma.value = ''
	form.aa.value = ''
	form.resumo.value = ''
}

function divPopUp(pagina, w ,h){
	var div = document.getElementById('divPopUp');
	div.style.display = "block";
	var texto;
	
	texto = "<table width='100%' height='100%' cellspacing='0' cellpadding='0'>" +
			"<tr><td align='center'>" +
			"<img src='imagens/bt_fechar.jpg' onclick='parent.abreFechaDiv(\"divPopUp\")' /><BR>" +
			"<iframe src='" + pagina + "' width='" + w + "' height='" + h + "' frameborder='0' scrolling='auto' class='bordaTabelaFrame'>" + pagina + "</iframe>" +
			"</td></tr></table>";
	div.innerHTML = texto;
}

function preeenchaCampo(id, nome, nomeCampoH, nomeCampoV){
	//var	form = document.getElementById(formulario);
	var campoH = document.getElementById(nomeCampoH);
	var campoV = document.getElementById(nomeCampoV);
	var div = document.getElementById('divPopUp');
	div.style.display = "none";
	
	//alert(nomeCampoH);
	//alert(nomeCampoV);
	
	campoH.value = id;
	campoV.value = nome;
	
}

function abreJanPopUp(pagina, nome, w, h){
	var features = "width=" + w +",height=" + h + ",scrollbars=yes";
	window.open(pagina,nome,features);
}

function ValidaEmail(txt)
{  
  if ((txt.length < 6) || (txt.indexOf("@") < 1) || (txt.indexOf('.') <= 4))
     return false;	
  else
  	 return true;
}

function validaFormOuvidoria(){
	var form = document.formOuvidoria;
	if(form.nome == ""){ alert("Preencha o campo nome"); return; }
	if(form.email == ""){ alert("Preencha o campo email"); return; }
	if(form.mensagem == ""){ alert("Preencha o campo mensagem"); return; }
	if(!ValidaEmail(form.email.value)){ alert("O email digitado não pode ser um email válido!"); return;}
	
	carregarDados("ouvidoriaEnviaEmail.php", "emailOuvidoria", "post", form, 1);
}