(function($){

  var fbLikeButtonReplacementText = "Facebook Like Button. Der " + 
    "tatsächliche Like Button wird aus Datenschutzgründen erst geladen, " +
    "nachdem Sie ein mal auf den Like Button geclicked haben.";

  $.fn.FacebookLikeReplacement = function(app_id, href)
  {
    this.empty();
    var img = $(document.createElement("img"));
    img.attr("src", "/images/social/doubleclick/fb.png");
    img.attr("width", "49");
    img.attr("height", "20");
    img.attr("alt", "Facebook Like");
    img.attr("title", fbLikeButtonReplacementText);
    img.css("cursor", "pointer");
    img.click(function(){
      var parent = img.parent();
      parent.empty();
      parent.FacebookLike(app_id, href)
    });
    this.append(fblike);
  }
  
  $.fn.FacebookLike = function(app_id, href)
  {
    var iframe = $(document.createElement("iframe"));
    var src = "//www.facebook.com/plugins/like.php?app_id=" + app_id + 
      "&href=" + href + ";send=false&layout=button_count&" + 
      "width=80&show_faces=false&action=like&colorscheme=light" +
      "&font&height=21";
    iframe.attr("src", src);
    iframe.attr("scrolling", "no");
    iframe.attr("frameborder", "0");
    iframe.attr("style", "border:none; overflow:hidden; width:110px; height:35px;");
    iframe.attr("allowTransparency", "true");
    this.append(iframe);
  }
  
  $.fn.GooglePlusOne = function()
  {
    var div = $(document.createElement("div"));
    div.attr("class", "g-plusone");
    div.attr("data-size", "medium");
    div.attr("data-count", "false");
    this.empty();
    this.append(div);
    var po = $(document.createElement('script'));
    po.attr("id", "plusone-script");
    po.attr("type", 'text/javascript');
    po.attr("async", "true");
    po.attr("src", 'https://apis.google.com/js/plusone.js');
    this.append(po);
  }
  
  $.fn.TwitterShareButton = function()
  {
    var link = $(document.createElement("a"));
    link.attr("href", "http://twitter.com/share");
    link.attr("class", "twitter-share-button");
    link.attr("data-count", "none");
    link.text("Tweet");
    this.append(link);
    var twitter = $(document.createElement("script"));
    twitter.attr("async", "true");
    twitter.attr("type", "text/javascript");
    twitter.attr("src", "http://platform.twitter.com/widgets.js");
    this.append(twitter);
  }
  
  $.fn.TwitterFollowButton = function()
  {
    var link = $(document.createElement("a"));
    link.attr("href", "https://twitter.com/parlamentAT");
    link.attr("class", "twitter-follow-button");
    link.attr("data-show-count", "false");
    link.attr("data-lang", "de");
    link.attr("data-show-screen-name", "false");
    link.text("@parlamentAT folgen");
    this.append(link);
    var twitter = $(document.createElement("script"));
    twitter.attr("async", "true");
    twitter.attr("type", "text/javascript");
    twitter.attr("src", "http://platform.twitter.com/widgets.js");
    this.append(twitter);
  }
})(jQuery);

