var generic = generic || {};
var brx = brx || {};

brx.socialshop = function () {
    var host = location.host;
    var url = host.match(/esteeonline\.com/) ? 'smashbox.like.socialamp.com' : 'smashbox.like.socialamp.com';
    
    return {
        renderLikeWidget: function( args ) {
            if ( !args.SOCIALAMP_ID || !args.node ) { return; }
            
            args.SOCIALAMP_ID = args.SOCIALAMP_ID.replace(/:/g, "-");
            
            jQuery.getJSON(
                'http://' + url + '/module/get/?keys=' + args.SOCIALAMP_ID + '&jsonp=?',
                function( data ) {
                    if ( args.node ) {
                        args.node.html( data[args.SOCIALAMP_ID] );
                    }
                }
            );
        },
        
        showFriendRecommended: function( args )  {
            if ( !args.SOCIALAMP_ID ) { return; }
            
            $('.' + args.SOCIALAMP_ID + ' .friend-recommends').show();
        },
        
        getMostPopular: function( args ) {            
            if ( !args.SOCIALAMP_PARENT_ID ) { return; }
            
            args.SOCIALAMP_PARENT_ID = args.SOCIALAMP_PARENT_ID.replace(/:/g, "-");
            
            jQuery.getJSON(
                'http://' + url + '/module/popular/?product_id=' + args.SOCIALAMP_PARENT_ID + '&jsonp=?',
                function( data ) {
                    $('.' + data + ' .most-popular').show();
                }
            );
        }
    };
}();

