function BlogPreview(container) {
  this.container_ = container;
}

BlogPreview.prototype.show = function(url, opt_noTitle) {
  var feed = new google.feeds.Feed(url);
  var preview = this;
  feed.load(function(result) {
    preview.render_(result, opt_noTitle);
  });
}

BlogPreview.prototype.render_ = function(result, opt_noTitle) {
  if (!result.feed || !result.feed.entries) return;
  while (this.container_.firstChild) {
    this.container_.removeChild(this.container_.firstChild);
  }

  var blog = this.createDiv_(this.container_, "blog");
  /*if (!opt_noTitle) {
    var header = this.createElement_("h3", blog, "");
    this.createLink_(header, result.feed.link, result.feed.title);
  }*/

  for (var i = 0; i < result.feed.entries.length; i++) {
	if (i > 2) {break}
    var entry = result.feed.entries[i];
    var div = this.createDiv_(blog, "entry");
    var linkDiv = this.createDiv_(div, "title");
    this.createLink_(linkDiv, entry.link, entry.title);
    if (entry.author) {
      //this.createDiv_(div, "author", "Posted by " + entry.author);
    }
	var str = entry.contentSnippet;
	var booty = str.replace(/&nbsp;/gi," ");
	booty = booty.replace(/&#124;/gi,"");
	booty = booty.replace(/&#233;/gi,"é");
	booty = booty.replace(/&#235;/gi,"ë");
	booty = booty.replace(/&#232;/gi,"è");
	booty = booty.replace(/&#187;/gi,"");
	booty = booty.replace(/&#8217;/gi,"'");
	booty = booty.replace(/&#246;/gi,"ö");
	booty = booty.replace(/&#160;/gi,"");
	booty = booty.replace(/&amp;/gi,"&");
	booty = booty.replace(/&#8211;/gi,"-");
	booty = booty.replace(/‘/gi,"'");
	booty = booty.replace(/’/gi,"'");
	
	booty = booty.replace(/ »/gi,"");
	
	booty = booty.replace(/FlexNieuws/gi,"");
	booty = booty.replace(/Vacaturesites/gi,"");
	booty = booty.replace(/HRMNieuws/gi,"");
	booty = booty.replace(/Arbeidsinspectie/gi,"");
	booty = booty.replace(/FlexFinancieel/gi,"");
	booty = booty.replace(/EU-werknemers/gi,"");
	booty = booty.replace(/CAONieuws/gi,"");

    this.createDiv_(div, "body", booty);
  }
  
  	
	$("a.bloga").css("color","#F26631");
	$("a.bloga").css("text-decoration","none");
	$("a.bloga").css("font-size","1em");
	$("a.bloga").css("font-weight","bold");
}

BlogPreview.prototype.createDiv_ = function(parent, className, opt_text) {
  return this.createElement_("div", parent, className, opt_text);
}

BlogPreview.prototype.createLink_ = function(parent, href, text) {
  var link = this.createElement_("a", parent, "bloga", text);
  link.href = href;
  link.target = "_blank"
  return link;
}

BlogPreview.prototype.createElement_ = function(tagName, parent, className,
                                                opt_text) {
  var div = document.createElement(tagName);
  div.className = className;
  parent.appendChild(div);
  if (opt_text) {
    div.appendChild(document.createTextNode(opt_text));
  }
  return div;
}
