var ID = "NOTICIA";

_firstResult[ID] = 0;
_maxResults[ID] = 25;
_orderColumn[ID] = "data";
_orderAsc[ID] = false;

function filter_NOTICIA() {
	filter = document.getElementById(ID + '_FILTER').value;
	
	if (filter != _filter[ID]) {
		_filter[ID] = filter;
		_firstResult[ID] = 0;
		NoticiaUserDWR.getSize(_filter[ID], 
			function (size) {
				createDisplayTableHeader(ID, size);
			}
		);
	} else {
		createDisplayTableHeader(ID, _size[ID]);
	}

	NoticiaUserDWR.filter(_filter[ID], _firstResult[ID], _maxResults[ID], _orderColumn[ID], _orderAsc[ID],
		function (noticias) {
			DWRUtil.removeAllRows(ID + '_LIST');
	
			var cellFunctions = [
				function(noticia) {
					return 	'<p>' +
								'<a href="noticia.do?method=select&id=' + noticia.id + '">' +
									'<b>' + noticia.titulo + '</b>' +
								'</a> ' +
								(
									noticia.exibeData
									?	'<font class="data">' +
											noticia.dataFull +
										'</font>'
									: 	''
								) +
							'</p>' +
							'<p align="justify">' +
								noticia.introducao +
							'</p>';
				}
			];
			
			DWRUtil.addRows(ID + '_LIST', noticias, cellFunctions, {
				escapeHtml:false,
				rowCreator:rowCreator
			});
		}
	);
}

if (window.addEventListener)
	window.addEventListener('load', filter_NOTICIA, false);
else
	window.attachEvent('onload', filter_NOTICIA);