KB.FbConnect =
{
    /**
    * initializes the Facebook API for use. this method should be the first Facebook API call to make.
    *
    * optional parameters:
    * ifUserConnected: either a function that takes a string argument for uid or string to a url to redirect
    * ifUserNotConnected: either a function that takes a string argument for uid or string to a url to redirect
    * reloadIfSessionStateChanged: bool
    * doNotUseCachedConnectState: bool
    * debugLogLevel: int
    *
    * Note 'ifUserConnected' and 'reloadIfSessionStateChanged' cannot be specified at the same time.
    * Note 'ifUserNotConnected' and 'reloadIfSessionStateChanged' cannot be specified at the same time.
    */
    initialize:function(fbConnectApi, ifUserConnected, ifUserNotConnected, reloadIfSessionStateChanged, doNotUseCachedConnectState, debugLogLevel){
        var params = new Object();
        if(ifUserConnected != null){ params.ifUserConnected = ifUserConnected; }
        if(ifUserNotConnected != null){ params.ifUserNotConnected = ifUserNotConnected; }
        if(reloadIfSessionStateChanged != null){ params.reloadIfSessionStateChanged = reloadIfSessionStateChanged; }
        if(doNotUseCachedConnectState != null){ params.doNotUseCachedConnectState = doNotUseCachedConnectState; }
        if(debugLogLevel != null){ params.debugLogLevel = debugLogLevel; }

        FB.init(fbConnectApi,"/xd_receiver.htm", params);
    },
    
    showBookmarkDialog:function(callback){
        FB.Connect.showBookmarkDialog(callback);
    },
    
    //popup request window
    popupRequestDialog:function(fbml, title){
        title = title || 'Invite your friends to check out Udemy!';
        width = 760;
        height = 680;

        this.popupDialog(fbml, title, width, height);
    },

    
    //popup dialog for fbml content
    popupDialog:function(fbml, title, width, height){
        fbml = fbml || ' ';
        title = title || ' ';
        width = width || 760;
        height = height || 650;

        var dialog = new FB.UI.FBMLPopupDialog(title);
        dialog.setFBMLContent(fbml);
        dialog.setContentWidth(width);
        dialog.setContentHeight(height);
        dialog.show();
    }
};