﻿
addthis_config = {}

jQuery.fn.addThis = function(options) {
    settings = jQuery.extend({
        username: "defaultName",
        language: "en",
        imageOnly: false
    }, options);

    addthis_config = { ui_language: settings.language, username: settings.username, data_track_clickback: true };

    // determine whether to include the normal or SSL version
    var addthisurl = (location.href.indexOf('https') == 0 ? 'https://' : 'http://') + 's7.addthis.com/js/250/addthis_widget.js?pub=' + settings.username

    var links = $(this);
    // include the script
    
    if (settings.imageOnly) {
        $.getScript(addthisurl, function() {
            links.each(function() {
                $(this).append('<img src="http://s7.addthis.com/static/btn/sm-plus.gif" width="16" height="16" alt="Bookmark and Share" style="border:0"/>')
                    .attr('href', 'http://www.addthis.com/bookmark.php?v=250&username=' + settings.username)
                        .mouseover(function() { return addthis_open(this, '', '[URL]', '[TITLE]'); })
                        .mouseout(function() { addthis_close(); })
                        .click(function() { return addthis_sendto(); });
            })
        }); 
    }
    else {
        $.getScript(addthisurl, function() {
            links.each(function() {
                $(this).append('<img src="http://s7.addthis.com/static/btn/lg-share-' + settings.language + '.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/>')
                    .attr('href', 'http://www.addthis.com/bookmark.php?v=250&username=' + settings.username)
                        .mouseover(function() { return addthis_open(this, '', '[URL]', '[TITLE]'); })
                        .mouseout(function() { addthis_close(); })
                        .click(function() { return addthis_sendto(); });
            })
        });
    }
    return this;
}
