var ShareIcons = new Class({
    Implements: [Options],
    options: {
        'services': [],
        'ele': false
    },
    services: {
        'delicious': {
            't': 'Bookmark on delicious',
            'u': 'http://del.icio.us/post?url=%url%&title=%title%'
        },
        'digg': {
            't': 'Digg this',
            'u': 'http://digg.com/submit?url=%url%&topic=travel_places'
        },
        'facebook': {
            't': 'Post to facebook',
            'u': 'http://www.facebook.com/sharer.php?u=%url%'
        },
        'stumble': {
            't': 'Stumble',
            'u': 'http://www.stumbleupon.com/submit?url=%url%&title=%title%'
        },
        'twitter': {
            't': 'Post to twitter',
            'u': 'http://twitter.com/home?status=%title%%20at%20%url%'
        }
    },
    initialize: function(ele, options) {
        this.setOptions(options);
        this.options.ele = $(ele);
        this.options.services.each(function(service) {
            this.render_button(service);
        }.bind(this));
    },
    render_button: function(t) {
        try {
            var serv = this.services[t];
        } catch(err) {
            var serv = false;
        }
        if(serv) {
            var url = this.services[t]['u'];
            url = url.replace('%url%', escape(window.location));
            url = url.replace('%title%', escape(document.title));
            var a = new Element('a', {
                'text': serv['t'],
                'href': url,
                'target': '_blank',
                'class': 'icon ' + t
            });
            a.inject(this.options.ele);
        }
    }
})

