// JavaScript Document
// From http://visualrinse.com/2008/09/24/how-to-build-a-simple-rss-reader-with-jquery/

function get_rss_feed() {
	//clear the content in the div for the next feed.
	$("#feedContent").empty();
 
	//use the JQuery get to grab the URL from the selected item, put the results in to an argument for parsing in the inline function called when the feed retrieval is complete
	$.get("rss-proxy.php?url=http://www.symantec.com/xml/rss/listings.jsp?lid=latestthreats30days", function(d) {
 
 
			var itemsArray = new Array();
			
			var count = 0;
 			
			//find each 'item' in the file and parse it
			$(d).find('item').each(function() {
	 
				//name the current found item this for this particular loop run
				var $item = $(this);
				// grab the post title
				var title = $item.find('title').text();
				// grab the post's URL
				var link = $item.find('link').text();
				// next, the description
				var description = $item.find('description').text().replace(/Type/g,'<br />Type');
				//don't forget the pubdate
				var pubDate = $item.find('pubDate').text().replace(/ 00:00:00 \+0000/g,'');
					//$item.find('pubDate').text();

				
	 
				// now create a var 'html' to store the markup we're using to output the feed to the browser window
				var html = "<div class=\"entry\"><a href=\"" + link + "\" target=\"_blank\"><h4 class=\"postTitle\">" + title + "<\/h4><\/a>";
				html += "<em class=\"date\">" + pubDate + "</em>";
				html += "<p class=\"description\">" + description + "</p><\/div>";
	
	 			itemsArray[count] = html;
				count++;
				
			});
			
			
			
			for (i=0; i<3; i++) {				
				$('#feedContent').append($(itemsArray[i]));	
				$('#left_column').append($("<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />"));
			}
			
		
	});
 
};
