﻿function share_on_facebook() {
    var u = location.href;
    var t = document.title;

    openWindow('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'share_on_facebook');
    return false;
}

function share_on_twitter() {
    var u = location.href;
    var t = document.title.replace('+', null);

    var l = u.length + t.length;

    if (l > 140) {
        var diff = l + 3 - 140 + 1;

        if (diff > 0 && diff < t.length) {
            t = t.substr(0, t.length - diff) + '...';
        }
    }

    openWindow('http://twitter.com/home?status=' + encodeURIComponent(t) + '+' + encodeURIComponent(u), 'share_on_twitter');
    return false;
}

function share_on_myspace(id) {
    var u = location.href;

    openWindow('handler/MySpace.aspx?u=' + encodeURIComponent(u) + '&i=' + id, 'share_on_myspace');
    return false;
}

function openWindow(t, n) {
    window.open(t, n, 'toolbar=0,status=0,width=600,height=400');
}