
/*social bookmark functions*/

function is_child_of(parent, child) {
    if (child != null) {
        while (child.parentNode) {
            if ((child = child.parentNode) == parent) {
                return true;
            }
        }
    }
    return false;
}
function fixOnMouseOut(element, event, JavaScript_code) {
    var current_mouse_target = null;
    if (event.toElement) {
        current_mouse_target = event.toElement;
    } else if (event.relatedTarget) {
        current_mouse_target = event.relatedTarget;
    }
    if (!is_child_of(element, current_mouse_target) && element != current_mouse_target) {
        eval(JavaScript_code);
    }
}
function openbookwidget(src) {
    url = location.href;
    title = document.title;
}
function closebookwidget(e) {
}
function addToFavs() {
    if (document.all) window.external.AddFavorite(url, title);
    else window.sidebar.addPanel(title, url, '');
}

// Takes the NodeId of the content being rendered and returns the shorten URL version with the Servername plus the s<nodeid>.htm for the URL rewriter.
function shortenURL(nodeId) {
    var splited = url.split('/');
    var serverURL = " http://" + splited[2];
    return encodeURIComponent(serverURL + "/s" + nodeId + ".htm");
}

function openwindow(socialsite, nodeId) {
    switch (socialsite) {
        case 'g':
            composedurl = "http://www.google.com/bookmarks/mark?op=add&bkmk=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(title);
            break;
        case 'm':
            composedurl = "http://www.myspace.com/Modules/PostTo/Pages/?c=" + encodeURIComponent(url) + "&t=" + encodeURIComponent(title);
            break;
        case 'f':
			composedurl = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(url) + "&t=" + encodeURIComponent(title);
            break;
        case 'l':
            composedurl = "https://favorites.live.com/quickadd.aspx?marklet=1&mkt=be-nl&url=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(title);
            break;
        case 'di':
            composedurl = "http://digg.com/submit?phase=2&url=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(title);
            break;
        case 'de':
            composedurl = "http://del.icio.us/post?v=4;url=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(title);
            break;
        case 'msn':
            composedurl = "http://reporter.it.msn.com/?fn=contribute&Title=" + encodeURIComponent(title) + "&URL=" + encodeURIComponent(url);
            break;
        case 'b':
            composedurl = "http://www.bligg.be/submit.php?url=" + encodeURIComponent(url);
            break;
        case 's':
            composedurl = "http://www.stumbleupon.com/submit?url=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(title);
            break;
        case 't':
            composedurl = "http://twitter.com/intent/tweet?text=" + encodeURIComponent(title) + shortenURL(nodeId) + "&source=DECO Proteste";
            break;
		 case 'tw':
            composedurl = "http://twitter.com/intent/tweet?text=" + encodeURIComponent(title) + encodeURIComponent(url) + "&source=DECO Proteste";
            break;	
        case 'ff':
            composedurl = "http://friendfeed.com/share?url=" + encodeURIComponent(url) + "&t=" + encodeURIComponent(title);
            break;

        default:
            addToFavs();
    }
    window.open(composedurl, 'bookmark', 'width=800,height=600,scrollbars=yes,toolbar=no,location=yes');
}

/* firendfeed
http://friendfeed.com/share?url=http%3A%2F%2Fwww.internetnews.com%2Fwebcontent%2Farticle.php%2F3805166%2FShareThis%2BExpands%2BSocial%2BWidget.htm&title=ShareThis Expands Social Widget - InternetNews.com
*/

/* twitter
http://twitter.com/home?status=http%3A%2F%2Fwww.internetnews.com%2Fwebcontent%2Farticle.php%2F3805166%2FShareThis%2BExpands%2BSocial%2BWidget.htm
*/
