// JavaScript Document
var html='';
$(function() {
	$(".rss_feed").each(function(i) {
		var $feed = $(this).attr("rel");
		var $num = $(this).find("span.num_items").text();
		var $div = $(this);
		
		$.get('/components/rss_feed/proxy.php?url='+$feed, function(xml){
			$("item", xml).each(function(){
				$(this).find("guid").each(function(){
					html += "<div class='item'><div class='link'><a target='_blank' class='rsslink' href='" +getNodeText(this) +"'> ";
				}).end().find("title").each(function(){
					html += getNodeText(this) + "</a></div>";
				}).end().find("pubDate").each(function(){
					html += "<div class='date'>" + getNodeText(this) + "</div>";
				}).end().find("description").each(function(){
					html += "<div class='description'>" + getNodeText(this) +"</div></div>";
				});
			});
			$div.append(html).slideDown("slow");
		}); 
	});
});

function getNodeText(node)
{
        var text = "";
        if(node.text) text = node.text;
        if(node.firstChild) text = node.firstChild.nodeValue;
        return text;
} 