﻿/* Create a namespace */
var NPBYGlobal = {};

/* Facebook comments reload*/
NPBYGlobal.facebookCommentsReload = function(config) {
   
    $("#fb-pagination a").click(function(e) {
        e.preventDefault();
        $("#fb-title").html($(this).attr("data-title"));
        $(this).addClass('active').siblings().removeClass('active');
        fbCommentsUrl = "http://" + config.host + "/comments/" + $(this).attr("data-key");
        fbComments = "<fb:comments href=\"" + fbCommentsUrl + "\" num_posts=\"" + config.numposts + "\" width=\"" + config.width + "\">";
        $("#fb-comments-plugin").html(fbComments);
        FB.XFBML.parse($('#fb-comments-plugin').get(0));
    });

    $('a.active').click(function(e) {
        e.preventDefault();
        return false; 
    });
};
