bam.share = (function() {
    // private methods
    var _settings = {
        prodRoot : "http://web.tigerwoodsfoundation.org/",
        pathname : document.location.pathname,
        contentId : null,
        title : "",
        summary : "",
        media : "news",
        topic : "golf",
        category : "sports",
        content : "text"
    };
    var _url = {};

    var _pop = function(url) {
        window.open(url,"sharer","width=626,height=436");
    };

    // public methods
    _self = {
        init : function(conf) {
            $.extend(_settings, conf);
            _url = {
                facebook : (
                    "http://www.facebook.com/sharer.php" +
                    "?u=" + encodeURIComponent(_settings.prodRoot + _settings.pathname +"?affiliateId=facebook_share") + 
                    "&t=" + encodeURIComponent(_settings.title)
                    ),
                digg     : (
                    "http://digg.com/submit" +
                    "?url=" + encodeURIComponent(_settings.prodRoot + _settings.pathname +"?affiliateId=digg_share") + 
                    "&title=" + encodeURIComponent(_settings.title) + 
                    "&bodytext=" + encodeURIComponent(_settings.summary) + 
                    "&media=" + encodeURIComponent(_settings.media) + 
                    "&topic=" + encodeURIComponent(_settings.topic)
                    ),
                yahoo_buzz : (
                    "http://buzz.yahoo.com/buzz" +
                    "?targetUrl=" + encodeURIComponent(_settings.prodRoot + _settings.pathname +"?affiliateId=digg_share") +
                    "&headline=" + encodeURIComponent(_settings.title) +
                    "&summary=" + encodeURIComponent(_settings.summary) + 
                    "&category=" + encodeURIComponent(_settings.category) + 
                    "&assettype=" + encodeURIComponent(_settings.content)
                    ),


                 "" : ""
            };
        },
        /**
         *  Binds the click handler to the sharing service link
         *
         *  @param {String} service Name of the sharing service
         *  @param {String|HTMLElement|jQuery} selector Link to be updated with the functionality
         *     OR
         *  @param {Object} serviceList Collection of services that should be bound {buzz : ".buzz a", yahoo : $(".yahoo a")}
         */
        bind     : function() {
            var serviceList = {};              // collection of services 
            var service = null;
            if (arguments.length === 2) {
                if(typeof(arguments[0]) === "string") {
                    serviceList[arguments[0]] = arguments[1];
                }
                else {
                    return false;
                }
            }
            else {
                serviceList = arguments[0];
            }
            
            for(service in serviceList) {
                (function(service) {
                    var $node = $(serviceList[service]);
                    $node.attr("href", _url[service]);
                    $node.unbind("click").click(function() {
                        _pop(_url[service]);
                        return false;
                    });
                }(service));
            }            
        },
        facebook : function(selector) {
            _self.bind("facebook", selector);
        },
        digg : function(selector) {
            _self.bind("digg", selector);
        },
        yahoo_buzz : function(selector) {
            _self.bind("yahoo_buzz", selector);
        }
    };
    return _self;
})()
