﻿function hideRootToolbar(obj) {
    document.getElementById('roottoolbar').style.display = "none"; 
}

function emailClick(emailSubject, emailBody) {
    var doctitle = encodeURIComponent(document.title);
    var docurl = encodeURIComponent(window.location);
    emailSubject = doctitle; 
    emailBody = docurl;
    webtrendsExecute('mailto');
    window.location = "mailto:?subject=" + emailSubject + "&amp;Body=" + emailBody;
}

function bookmarkClick() {
    webtrendsExecute('addfavorite');
    window.external.AddFavorite(window.location, document.title); 
}

function socialClick(socialNetworkURL) {
    var data = {}, metas = document.getElementsByTagName("meta"); 
    for (var i = 0; i < metas.length; i++) {
        if (metas[i].getAttribute("name") == "description")
            data.description = encodeURIComponent(metas[i].getAttribute("content").substr(0, 350));
    }
    data.title = encodeURIComponent(document.title);
    data.href = encodeURIComponent(window.location);
    socialNetworkURL = socialNetworkURL.replace(/#pageurl#/i, data.href);
    socialNetworkURL = socialNetworkURL.replace(/#pagetitle#/i, data.title);
    socialNetworkURL = socialNetworkURL.replace(/#pagedescription#/i, data.description);
    webtrendsExecute(socialNetworkURL); 
    window.open(socialNetworkURL, 'bpioShareBarPage');
}

function webtrendsExecute(sharebarURL) {
    sharebarURL = sharebarURL.toLowerCase(); var sharebarNetwork = 'unknown'
    if (sharebarURL.indexOf('mailto') > -1) {
        sharebarNetwork = 'Email'; 
    }
    else if (sharebarURL.indexOf('addfavorite') > -1) { 
        sharebarNetwork = 'Bookmark'; 
    }
    else if (sharebarURL.indexOf('digg') > -1) {
        sharebarNetwork = 'Digg'; 
    }
    else if (sharebarURL.indexOf('delicious') > -1) {
        sharebarNetwork = 'Delicious'; 
    }
    else if (sharebarURL.indexOf('reddit') > -1) {
        sharebarNetwork = 'Reddit'; 
    }
    dcsMultiTrack('DCS.dcsuri', '/w14bpio/sharebar/' + sharebarNetwork.toLowerCase(), 'WT.ti', 'Share: ' + sharebarNetwork, 'WT.dl', 1);
}
