function nokiablogsFeed() {
	if( !$("#nokiablogfeed").length ) {
		return;
	}
	$.get('/aspx/HTTPFetch.aspx?url=http%3A//feeds2.feedburner.com/NokiaBlogsFeed',
		function(data) {
			$("#nokiablogfeed").empty();
			xml = $(data);
			xml.find('item').each(
				function(i) {
					if( i >= 3 )
						return;
					var permalink = $(this).find('link:eq(0)').text();
					var title = $(this).find('title:eq(0)').text();
					$("#nokiablogfeed").append( "<p><a href=\""+permalink+"\" title=\"blogs.nokia.com: "+title+"\">"+title+"</a></p>" );
				}
			);
			$("#nokiablogfeed a").click(
        	    function() {
                    window.open($(this).attr('href'));
                    return false;
        	    }
        	)
		}
	);
}

function fbFeed() {
	if( !$("#facebookfeed").length ) {
		return;
	}
	$.get('/aspx/HTTPFetch.aspx?url=http%3A//www.facebook.com/feeds/page.php%3Fformat%3Datom10%26id%3D36922302396',
		function(data) {
			$("#facebookfeed").empty();
			xml = $(data);
			xml.find('entry').each(
				function(i) {
					if( i >= 3 )
						return;
					var permalink =  $(this).find('link:eq(0)').attr('href');
					if (permalink.indexOf("facebook.com") == -1)
					    permalink = "http://www.facebook.com" + permalink;
					var title = $(this).find('title:eq(0)').text();
					$("#facebookfeed").append( "<p><a href=\""+permalink+"\" title=\"Facebook: "+title+"\"><strong>Nokia</strong> "+title+"</a></p>" );
				}
			);
			$("#facebookfeed a").click(
        	    function() {
                    window.open($(this).attr('href'));
                    return false;
        	    }
        	);
		}
	);
}

$(document).ready(
    function() {
        nokiablogsFeed();
        fbFeed();
    }
);
