// JavaScript Document
// Autor: Digisoft Informática.
// Data de alteração: 25/03/2010.

window.addEvent('domready', function() {

	listarNoticias();

});

function listarNoticias(){
    var params = {
        'act' : 'listarUltimasManchetes'
    };
    new Request.JSON ({
        url: 'noticia_ctrl.php?' + Hash.toQueryString(params),
        async : false,
        onComplete: function(jsonObj){
			exibirNoticiasNaTela(jsonObj);		
        }
    }).send();
}

function exibirNoticiasNaTela(jsonObj){
	var td_exibeNoticia = $('exibeNoticias');
	var texto = "";
    texto += '<table width="332" border="0" cellspacing="0" cellpadding="0">';
	texto += '<tr><td height="10"></td><td></td><td></td><td></td></tr>';

	for (var i=0; i<jsonObj.length; i++) {
		objNoticia = jsonObj[i];
	
		texto += '<tr>';
		texto += '<td width="15" valign="top"><img src="images/icon_noticia.gif" /></td>';
		texto += '<td width="3"></td>';
		texto += '<td width="300" valign="top" align="left"><span class="txt_normal">' + decode_utf8(objNoticia.titulo) + '...</span></td>';
		texto += '<td>&nbsp;</td>';
		texto += '</tr>';
		texto += '<tr>';
		texto += '<td height="10"></td>';
		texto += '<td></td>';
		texto += '<td valign="middle" align="left"><a href="index.php?fuseaction=noticias&act=leNoticia&id=' + decode_utf8(objNoticia.id) + '" class="link">(leia mais...)</a></td>';
		texto += '<td>&nbsp;</td>';
		texto += '</tr>';
		texto += '<tr>';
		texto += '<td height="4"></td>';
		texto += '<td></td>';
		texto += '<td valign="middle" align="left" height="10"><span class="txt_apagado_menor">em '+ decode_utf8(objNoticia.data) + ' as ' + decode_utf8(objNoticia.hora) + '</span></td>';
		texto += '<td>&nbsp;</td>';
		texto += '</tr><tr><td height="3"></td><td></td><td></td><td></td></tr>';
		texto += '<tr>';
		texto += '<td height="1"></td>';
		texto += '<td></td>';
		texto += '<td bgcolor="#D0DDF0"></td>';
		texto += '<td bgcolor="#D0DDF0"></td>';
		texto += '</tr>';
		texto += '<tr><td height="7"></td><td></td><td></td><td></td></tr>';
	}
					
	texto += "</table>";	
	td_exibeNoticia.innerHTML = texto;
	
}
