$(document).ready(function() {
	 resizeCols();	
});

function resizeCols() {
	var h1 = $('#issue').height();
	var h2 = $('#context').height();
	var box = $('.c2').height();
	if ( h1+box < h2)
		$('#issue').height(h2-box-38);
	else
		$('#context').height(h1+box+38);
}

function geraNews() {
	$.ajax({
	  url: 'news.xml',
    type: 'GET',
    dataType: 'xml',
    timeout: 1000,
    error: function(){
       alert('Error loading XML document');
    },
    success: function(xml){
			var _titulo 			= "";
			var _data 		 		= "";
			var _fonte		 		= "";
			var _imagem		 		= "";
			var _conteudo  		= "";

			$(xml).find('noticia').each(function(){
				_titulo 			= $("titulo", 			this).text();
				_data 				= $("data", 	 	 		this).text();
				_fonte 				= $("fonte", 	 	 		this).text();
				_imagem				= $("imagem",	 	 		this).text();
				_conteudo			= $("conteudo",	 		this).text();
				var item_text = "<small>"+_data+"</small><h4>"+_titulo+"</h4><small>Fonte: <strong>"+_fonte+"</strong></small><img src="+_imagem+" border='0' class='imgNewsLeft' /><p>"+_conteudo+"</p><hr><div class='goTop'><a href='#'>Voltar ao topo</a></div>";
				$("#boxNews").append(item_text);
			});
			$('#context').height($('#boxNews').height()+50);
			resizeCols();	
		}		
	});	
}

function geraNewsHome() {
	$.ajax({
	  url: 'news.xml',
    type: 'GET',
    dataType: 'xml',
    timeout: 1000,
    error: function(){
       alert('Error loading XML document');
    },
    success: function(xml){
			var _titulo_home 	= "";
			var _thumb			 	= "";
			var _chapeu			 	= "";

			$(xml).find('noticia').each(function(){
				_titulo_home	= $("titulo_home", 	this).text();
				_thumb				= $("thumb",	 	 		this).text();
				_chapeu				= $("chapeu",	 	 		this).text();
				var item_home = "<p class='f'><img src="+_thumb+" alt='noticia' width='225' height='60'></p><h2>"+_titulo_home+"</h2><p>"+_chapeu+"<br><a href='sobre.php?s=noticias'>Veja mais..</a></p>";
				$("#boxNews-home").append(item_home);
				return false;
			});
		}		
	});	
}