$(document).ready(function(){
	//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("/js/rssproxy/rss.php", function(d) {
 
		//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();
			//don't forget the pubdate
			var pubDate = $item.find('pubDate').text();
			
			// next, the description
			var description = $item.find('description').text();
			//$(description).find("p").find("img").remove();
			var desc = $(description);
			desc.find("img").remove();
			desc.find("h1").remove();
			desc.find("a").remove();
			desc.find("br").remove();
			//desc.find("span").remove();
			var rsstext;
			desc.each(function(index, value){
				if(value.tagName == "P") rsstext= $(value).html();	
			});
			
			var textarr = rsstext.split(/\s/).slice(0,18);
			//slice(0, 10);

			rsstext = textarr.join(" ");	
			// now create a var 'html' to store the markup we're using to output the feed to the browser window
			var html = "<h4><a class=\"nieuws\" href=\"" + link + "\" target=\"_blank\">" + title + "</a></h4>";
			html += "<p>"+rsstext+"...</p>";
			html += "<a class=\"nieuwslm\" href=\""+link+"\">Lees meer »</a>";
			html += "<div class=\"nieuwssep\"></div>";
			
			//put that feed content on the screen!
			$('#nieuws').append($(html));  
		});
	});
});
