$(document).ready(function() {
	
	var $clicked = "";

	 $.ajax({  
     	type: "GET",  
    	 url: "/scripts/rssfeed.php",  
		 contentType: "application/x-www-form-urlencoded; charset=iso-8859-1",
     	dataType: "json",  
     	success: parseXml

 	});  
	
	var rssString = "";

	function parseXml(data) {
		var $json = data['items'];
		$.each($json, function(i, object) {
			var titleValue;
			var linkValue;
			var fullDate;
			$.each(object, function(property, value) {
				
				if(property == "title"){
					titleValue = value;
				}
				if(property == "link"){
					linkValue = value;
				}
				if(property =="pubDate"){
					dateValue = value;
					
					var regSpace = new RegExp("[ ]", "g");
					var dateSplitValue = dateValue.split(regSpace);

					fullDate = dateSplitValue[2] + ' ' + dateSplitValue[1] + ', ' + dateSplitValue[3]; // grab day and month
					
				}
				
				
				
				
			});
			rssString += '<a href=\"' + linkValue + '\" target="_blank">' + titleValue + '</a>\<br\>\<span class=\"date\"\>' + fullDate + '\<\/span\>\<br\>\<br\>';
		});
		
		$("#home_hollywood_joe").html(rssString);
		
	}
});
