if(typeof LOP === 'undefined') {
    var LOP = {};
}

(function($) {
    var W = this, D = this.document;
    
    LOP.FBC = {
        init: function() {
            var fbAppId = location.pathname.toLowerCase().indexOf('/contentmanagerdata/sites/aspnet/') > -1 ? '119266961456081' : '109799152407830';
            
            FB.init({
                appId  : fbAppId,
                status : true,
                cookie : true,
                xfbml  : false
            });
        },
        checkStatus: function(datas) {
            FB.getLoginStatus(function(response) {
                if(response.session) {
                    LOP.FBC.userFbId = response.session.uid;
                    
                    if(datas.logged) {
                        datas.logged();
                    }
                } else {
                    if(datas.notLogged) {
                        datas.notLogged();
                    }
                }
            });
        },
        loadContent: function() {
            LOP.popinMaskType = 'coreMaskPopinFBLoading';
            LOP.popins.add({
                url: l10n.FB.url.contentLoading,
                id: 'FBLoading',
                processHTML: false,
                refresh: true
            });
        },
        userFbId: ''
    };
    
    LOP.popinOpeningActions.FBLoading = function() {
        this.position();
    };
    
    $(D).ready(function() {
        if(!D.getElementById('fb-root')) {
            $('body').append('<div id="fb-root"></div>');
        }
        LOP.FBC.init();
    });
})(jQuery);
