function check_filled_evento()
{
	var campos = "";
	selectAll('curEventos[]');
	if(!getImputValue('curTitulo'))
		campos += "- Título do evento";
	if(!getImputValue('curResponsavel'))
		campos += "\n- Nome do responsável";
	if(!getImputValue('curDtInicio'))
		campos += "\n- Data de início";
	if(!getImputValue('curDtFim'))
		campos += "\n- Data de fim";
	if(!getSelectValue('curEventos[]'))
		campos += "\n- Evento(s)";
		
	if(campos != "")
		return window.alert("Favor verificar o preenchimento adequado dos seguintes campos:\n"+campos);
	
	document.forms[0].submit();
}


function check_filled_etapa()
{
	var campos = "";
	
	if(!getImputValue('eveTitulo'))
		campos += "- Título do evento";
	if(!getImputValue('eveCargaHor'))
		campos += "\n- Carga Horária";
	if(!getImputValue('eveData'))
		campos += "\n- Data da realização";
	if(!getImputValue('eveDescricao'))
		campos += "\n- Descrição";
	
	if(campos != "")
		return window.alert("Favor verificar o preenchimento adequado dos seguintes campos:\n"+campos);
	else
		document.forms[0].submit();
}

function check_filled_profes()
{
	var campos = "";
	
	if(!getImputValue('profCPF'))
		campos += "- CPF";
	if(!getImputValue('profNome'))
		campos += "\n- Nome";
	if(!getImputValue('profRG'))
		campos += "\n- RG";
	if(!getImputValue('profEmissorRG'))
		campos += "\n- Emissor do RG";
	if(!getImputValue('profDtNasc'))
		campos += "\n- Data de nascimento";
	if(!getSelectValue('profSexo'))
		campos += "\n- Sexo";
	if(!getImputValue('profTelRes') && !getImputValue('profTelCel'))
		campos += "\n- Informe pelo menos um telefone";
	if(!getImputValue('profLogradouro'))
		campos += "\n- Logradouro";
	if(!getImputValue('profNumero'))
		campos += "\n- Número";
	if(!getImputValue('profBairro'))
		campos += "\n- Bairro";
	if(!getImputValue('profCEP'))
		campos += "\n- CEP";
	if(!getImputValue('profCidade'))
		campos += "\n- Cidade";
	if(!getSelectValue('profUF'))
		campos += "\n- Estado";
		
	if(campos != "")
		return window.alert("Favor verificar o preenchimento adequado dos seguintes campos:\n"+campos);
	
	document.forms[0].submit();
}

function cancel(pagina)
{
	var resp = confirm("Deseja realmente cancelar esta ação?");
	if(resp == true)
		window.location = pagina;
}


function FillCamposProf()
{
	var cpf = document.getElementById('profCPF');
	if(cpf.value.length == 14)
	{
		url = "/dev.php?system=extensao&action=professores.fill_campos&cpf="+ cpf.value;
	
		ajax1 = new ajax; 
		ajax1.onreadystatechange = function()
		{
			if (ajax1.readyState == 4 && ajax1.status == 200)
			{
				var resposta = ajax1.responseXML;
				var field = resposta.getElementsByTagName('input');
				
				for(i=0; i<field.length; i++)
				{
					cam = field[i].getAttribute("id");
					document.getElementById(cam).value = field[i].childNodes[0].data.replace("(+)", "");
				}
				
				var field = resposta.getElementsByTagName('select');
				for(i=0; i<field.length; i++)
				{
					cam = field[i].getAttribute("id");
					setSelectValue("form1", cam, field[i].childNodes[0].data.replace("(+)", ""), "");
				}
			}
		}
		ajax1.open("POST", url, true ); 
	
		ajax1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		ajax1.send();	
		
	}
}

var ajx = null;
//var resposta = null;
function ajaxRequestHTML2(destino, url)
{
	dest = document.getElementById(destino);
	ajx = new ajax();
	ajx.onreadystatechange = function()
	{
		
		if(ajx.readyState == 4 && ajx.status == 200)
		{
			resposta = ajx.responseText;
			
			if(resposta == null)
				dest.innerHTML = 'NULL!';
			else
				dest.innerHTML = resposta;
			
			hidde_div();
			hiddeLoading();
		}
	}
	ajx.open("POST", url, true);  
	ajx.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	
	cria_fundo();
	initLoading();
	
	ajx.send('');
}

function getAluno()
{
	var cpf = document.getElementById('cpf').value;
	var url = "dev.php?system=extensao&action=cadastro.get_aluno&cpf="+cpf;
	
	ajaxRequestHTML2('aluno', url);
}

function hidde_help()
{
	try
	{
		document.body.removeChild(help);
		help = '';
	}
	catch(err)
	{
		var error = err;
	}
}
var help = '';
function balao(msg)
{
	if(help != '')
	{
		document.body.removeChild(help);
		help = '';
	}
	help = document.createElement('div');
	help.setAttribute('id', 'help');
	help.setAttribute('className', 'balao_help');
	
	var inner = "<table style='background-repeat:no-repeat' width='391' height='200' border='0' cellpadding='0' cellspacing='0' background='/imagens/balao.png'>"
	inner +=  "<tr>"
	inner +=    "<td width='21' height='20' nowrap='nowrap'>&nbsp;</td>"
	inner +=    "<td width='338' nowrap='nowrap'>&nbsp;</td>"
	inner +=    "<td width='32' nowrap='nowrap'>&nbsp;</td>"
	inner +=  "</tr>"
	inner +=  "<tr>"
	inner +=    "<td height='91' nowrap='nowrap'>&nbsp;</td>"
	inner +=    "<td align='justify' valign='middle'>" + msg + "</td>"
	inner +=    "<td nowrap='nowrap'>&nbsp;</td>"
	inner +=  "</tr>"
	inner +=  "<tr>"
	inner +=    "<td nowrap='nowrap'>&nbsp;</td>"
	inner +=    "<td nowrap='nowrap'>&nbsp;</td>"
	inner +=    "<td nowrap='nowrap'>&nbsp;</td>"
	inner +=  "</tr>"
	inner +="</table>";
	
	document.body.appendChild(help);
	
	document.getElementById('help').innerHTML = inner;
	
	var l = document.body.scrollLeft + event.clientX;
	var t = document.body.scrollTop + event.clientY - 205;
	
	if(t < 200)
		t += 200;
		
	document.getElementById('help').style.left = l;
	document.getElementById('help').style.top = t

}
