(function($) {
    var init = {
        facebook : function() {
            var fb = { aid:'foot-social', bid:'button-social-fb', hid:'head-social', fid:'social-fb-iframe', sid:'body-social-fb' };
            if (!($('#'+fb.hid).size() > 0 && $('#'+fb.aid).size() > 0)) {
                return false;
            }
            var fs = { color:'light', layout:'button_count', font:'arial', height:21, width:125 };
            var ps = function() {
                var bp = $('#'+fb.bid).offset();
                $('#'+fb.sid).css({ 'position':'absolute','bottom':'80px','left':'50%','margin-left':'-125px'});
                $('a[name="fb_share"]').first().attr('href','http://www.facebook.com/sharer.php?u='+$.browser.hostaddr);
            };
            
            $('#'+fb.hid).append('<a href="#'+fb.sid+'" id="'+fb.bid+'"><span class="icon-social icon-social-fb"><span class="none">Facebook</span></span></a>');
            $('#'+fb.aid).append(''
                + '<scr' + 'ipt src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascr' + 'ipt"></scr' + 'ipt>'
                + '<span id="'+fb.sid+'" class="'+fb.sid+'">'
                  + '<a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php?u=http://'+window.location.hostname+'">Teilen</a>'
                + '</span>'
            );
            $('#'+fb.sid).show(0);
            var fbi = $('<iframe></iframe>')
                .attr('id', fb.fid).attr('name', fb.fid)
                .attr('src', 'http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.heinotrusheim.de%2F&layout='+fs.layout+'&colorscheme='+fs.color+'&font='+fs.font+'&show_faces=false&width='+fs.width+'&height'+fs.height+'&action=like')
                .attr('frameborder', 'no').attr('scrolling', 'no')
                .attr('width', fs.width).attr('height', fs.height);
            fbi.css({ 'border':'none', 'overflow':'hidden', 'width':fs.width+'px', 'height':fs.height+'px' });
            $('#'+fb.sid).prepend(fbi);
            ps();
            $('#'+fb.sid).hide();
            $('#'+fb.bid).click(function() {
                if ($('#'+fb.sid).css('display') !== 'none') {
                    $('#'+fb.sid).hide();
                    $(this).removeClass('active');
                } else {
                    $(this).addClass('active');
                    $('#'+fb.sid).show();
                    ps();
                }
                return false;
            });
        }
	// ... bei Bedarf weitere Init-Functions
    };
    $(document).ready(function() {
        init.facebook();
	// ... bei Bedarf weitere Init-Calls
    });
})(jQuery);
