var recentPosts = new google.feeds.Feed("http://blog.vgreano.com/rss");
recentPosts.setNumEntries(10); //Show max entries
recentPosts.load(formatoutput);

function formatoutput(result){
	if (!result.error){
		var thefeeds=result.feed.entries;
		populateFeed(thefeeds);	
	}
	else{//if error fetching feed, alert human readable error message
	alert(result.error.message);
	}
}

function populateFeed(thefeeds){
	//populate the starting divs
	var title = "";
	var theUrl = "";

	for (var i=0; i<thefeeds.length; i++){
		
		theUrl = thefeeds[i].link;
		
		title = thefeeds[i].title;//.replace("'", " ");
		titleTag = thefeeds[i].title;

		//title = thefeeds[i].title.replace('"', ' ');

		//title = title.replace("'","").replace('"','').replace("&#34;", "").replace("&#39;", "");
		titleTag = title.replace("'","").replace('"','').replace("&#34;", "").replace("&#39;", "");

		if ((title.length) > 62){	
			title = title.substring(0, 62) + "...";
		}

		//document.getElementById().innerHTML = "<div class='recentPost'><a  href='" + thefeeds[i].link + "' title='" + titleTag + "'>" + title + "</a>";
		var divTag = document.createElement("div");
		divTag.className = "recentPostDiv";
		divTag.innerHTML = "<a href='" + theUrl + "' title='" + titleTag + "'>" + title + "</a>";
		document.getElementById('recentPostsContainer').appendChild(divTag);
	}
}
