/* Title    : Facebook Initialization
 * Author   : Armande Bayanes (tuso@programmerspride.com)
 **/

window.fbAsyncInit = function() {

    var params = {            
        status  : true, /* Enable checking of login status. */
        cookie  : true, /* Enable cookies to allow the server to access the session. */
        xfbml   : true, /* Enable parsing of XFBML. */
        oauth   : true  /* Enable OAuth 2.0 */
    };
    
    /* Only for FB connect. */
    if(typeof(FACEBOOK_APP_ID) != 'undefined') {
        jQuery.extend(params, { appId : FACEBOOK_APP_ID });
    }

    FB.init(params);
};

jQuery(function(){
    
    var fb_root = jQuery('#fb-root');
    if(! fb_root || ! fb_root.length) {
        jQuery('body').append('<div id="fb-root"></div>');
    }
    
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
});
