// JavaScript Document

function preencheNoticia()
{
	if(request.readyState == 4){ // A PÁGINA FOI CARREGADA
		if(request.status == 200){ // A PÁGINA FOI CARREGADA CORRETAMENTE
			//alert(request.responseText);
			var info = eval('('+request.responseText+')');
			
			document.getElementById('tituloNoticia').innerHTML	= info['tituloNoticia'];
			document.getElementById('subTituloNoticia').innerHTML	= info['subTituloNoticia'];
			document.getElementById('textoNoticia').innerHTML	= info['textoNoticia'];
			
			// Esconde o loading
			showLoading('false');
		}
	}
	else
	{
		showLoading('true');
	}
}

function mostraNoticia(id)
{
	createRequest(); // cria o objeto de requisição em AJAX: request
	
	var url = "noticias_ajax.php?id="+escape(id)+"&antiCache="+Math.round(Math.random()*10000000);
	//alert(url);
	request.open('GET',url,true);
	request.onreadystatechange = preencheNoticia;
	request.send(null);
}