var AUBIFB = {
  fbxmls: [],
  add_fbxml: function(selector, fbxml){
    if(fbxml) $(selector).html(fbxml);
    this.fbxmls[this.fbxmls.length] = selector;
  },
  render_fbxmls: function() {
    $.each(this.fbxmls, function() {
      FB.XFBML.parse($(String(this))[0]);
    });
  },
  publish_this: function() {
    FB.ui({
      method: 'stream.publish',
      message: $("#og_title").text(),
      attachment: {
        name: $("#og_title").attr("content"),
        caption: $(".header_bereichskennung").text(),
        description: $("#meta_desc").attr("content"),
        href: document.location.href,
        media: [{ type: 'image', src: $("#og_image").attr("content"), href: document.location.href}] 
      },
      action_links: [
        { text: 'Code', href: document.location.href }
      ],
      user_message_prompt: 'Teile mit Anderen was Du über '+$(".header_bereichskennung").text()+'denkst'
    });
  }
};

window.fbAsyncInit = function() {
  FB.init({
    appId: '102987176416113', 
    status: true, 
    cookie: true,
    xfbml: false
  });
  
  AUBIFB.render_fbxmls();
};

$(function() {
  var e = document.createElement('script');
  e.type = 'text/javascript';
  e.src = document.location.protocol +
    '//connect.facebook.net/de_DE/all.js';
  e.async = true;
  document.getElementsByTagName('head')[0].appendChild(e);
});
