
function apply_commenter_data() {
    FB_RequireFeatures(["XFBML","Api"], function()
    {
        FB.Facebook.init(window.api_key, window.xd_receiver_url);

        // Get the current logged in user
        var session = FB.Facebook.apiClient.get_session();
        if (!session) return;
        var viewerId = session.uid;
        if (!viewerId) return;

        // Find the various FB users we're rendering
        var FBIds = new Array();
        jQuery("fb:name").each(function() {
            FBIds.push($(this).getAttribute("uid"));
        });

        // Highlight your comments
        jQuery(".comment-fb-" + viewerId).each(function() {
            $(this).addClass("comment-friend");
        });

        // Find friends and highlight theirs
        FB.Facebook.apiClient.fql_query("SELECT uid2 FROM friend WHERE uid1=" + viewerId + " AND uid2 IN (" + FBIds.join(',') + ")", function(result, ex)
        {
            for (var i = 0; i < result.length; i++) {
                jQuery(".comment-fb-" + result[i]["uid2"]).each(function() {
                    $(this).addClass("comment-friend");
                });
            }
        });

        // Hide the URL and "remember me" boxes
        mtHide('comments-open-data');
    });
}

function send_story(post_url, post_title, story_template_id) {
        FB_RequireFeatures(["Api", "Connect"], function()
                {
                        FB.Facebook.init(window.api_key, window.xd_receiver_url);
                        FB.Connect.get_status().waitUntilReady(function(status) 
                        {





                        });

                });



            FB_RequireFeatures(["Connect"], function() { 

 

                    FB.ensureInit(function() { 

 

                    var message = ''; 

                    var attachment = { 

                        'name': post_title, 

                        'href': post_url, 

                        'caption': '{*actor*} commented entry on laleva.org', 

                        'description': 'Interesting article!', 

                        "media": [{ "type": "image", "src": "", "href": ""}] 

                    };

                    //var action_links = [{ post_title: '', post_url: ''}]; 

                    //FB.Connect.streamPublish(message, attachment, action_links, null, "http://clubfarumaldives.info", callback, false, null);  

                    FB.Connect.streamPublish(message, attachment, null, null, "http://www.laleva.org", callback, false, null);  

                });

            });

            function callback(post_id, exception) {

                //do smth 

            }

}

function facebook_logout() {
    FB_RequireFeatures(["Api", "Connect"], function() {
        FB.Facebook.init(window.api_key, window.xd_receiver_url);

        // Get the current logged in user
        var session = FB.Facebook.apiClient.get_session();
        if (!session) return;
        var viewerId = session.uid;
        if (!viewerId) return;

        FB.Connect.logout();
    });
}

