function validaInformativos()
{
	var msg = document.getElementById('msg_aviso');
	var retorno = true;
	
	msg = '<br> <b>Campos obrigatórios:</b> ';
	
	var nome = document.getElementById('fnomei');
	trim(nome);
	if ( nome.value == '' )
	{
		msg += 'Nome';
		nome.focus();
		retorno = false;
	}
	
	var email = document.getElementById('femaili');
	trim(email);
	if ( email.value == '' )
	{
		msg += ', Email';
		email.focus();
		retorno = false;
	}
	else if ( validaEmail(email) == false )
	{
		msg += ', Email inválido';
		email.focus();
		retorno = false;
	}
	
	if ( retorno == false )
	{
		msg += ' não preenchidos';
		msgAviso(msg);
		return false;
	}
	else
	{
		cadastraInformativos();
		nome.value = '';
		email.value = '';
	}
}

function cadastraInformativos()
{
	iniciaAjax();

	var conteudo = document.getElementById('fnomei').value;
	conteudo = conteudo+'___'+document.getElementById('femaili').value;

	if ( !Ajax )
	{
		alert("Não foi possivel iniciar o Ajax!");
		return;
	}
	else
	{
		Ajax.onreadystatechange = function(){mostraInformativos()};
		Ajax.open("GET","../xml/xml_informativos.php?conteudo="+conteudo, true);
		Ajax.send(null);
	}
}

function mostraInformativos()
{
	if ( Ajax.readyState == 4 && Ajax.status == 200 )
	{
		var xmlInformativos = Ajax.responseXML;
		var msg = xmlInformativos.getElementsByTagName('msg');
		
		if ( xmlInformativos.hasChildNodes() )
		{
			for ( i=0; i<msg.length; i++ )
			{
				var msg2 = msg[i].childNodes;
		 		msgAviso("<br><center><b>"+msg2[0].nodeValue+"</b></center>");
			}
		}
	}
}
