mdp.app.facebookSDK = function(){

    thisAppID = mdp.util.fb.applicationId;

    window.fbAsyncInit = function() {

    /* Set the default to BHG if no AppID is found */
        FB.init({appId: thisAppID, status: true, cookie: true, xfbml: true});

            if(mdp.fbLikeCallBackOptions != null){
                FB.Event.subscribe('edge.create', function(href, widget) {
                   SocialMediaService.submitNewRecommendation(mdp.fbLikeCallBackOptions.brandId ,
                                mdp.fbLikeCallBackOptions.contentType ,
                                mdp.fbLikeCallBackOptions.contentId ,
                                mdp.fbLikeCallBackOptions.childId ,
                                mdp.fbLikeCallBackOptions.channel ,
                                mdp.fbLikeCallBackOptions.subChannel ,
                                mdp.fbLikeCallBackOptions.userId  ,
                                 function(remoteResult){
                                    locked = false;
                                    if(remoteResult.statusCode == 0){
                                        /*alert("liked on meredith");*/
                                        }
                                    else{
                                        /*alert("Your request cannot be processed at this time.  Please try again later.");*/
                                    }
                                });
                        });
                    }
        };

    function init(){

        var b = document.getElementsByTagName('body') [0];
        var d = document.createElement('div');
            d.id = "fb-root";
            b.appendChild(d);
        var e = document.createElement('script');
            e.async = true;
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            document.getElementById('fb-root').appendChild(e);

    }

    /* ---[ RUN ]--- */
    init();
};

$(document).ready(function(){
    mdp.facebookSDK = new mdp.app.facebookSDK();
});


