﻿//init dropdown
var endcard_share_links = {
    "btn-share_live_end": "https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url={url}&title={title}&top=0",
    "btn-share_digg_end": "http://digg.com/submit?phase=2&url={url}&title={title}",
    "btn-share_facebook_end": "http://www.facebook.com/sharer.php?u={url}&t={title}",
    "btn-share_delicious_end": "http://del.icio.us/post?url={url}&title={title}",
    "btn-share_stumbleupon_end": "http://www.stumbleupon.com/submit?url={url}&title={title}",
    "btn-share_reddit_end": "http://reddit.com/submit?url={url}&title={title}",
    "btn-share_newsvine_end": "http://www.newsvine.com/_tools/seed&save?u={url}&h={title}"
};

var this_title = escape(document.title);
var this_url = location.href;

$(document).ready(function()
{
    for (item in endcard_share_links)
    {
        var anchor = endcard_share_links[item].replace("{url}", this_url).replace("{title}", this_title);

        $('#' + item).attr("href", anchor);
        $('#' + item).attr("target", "_blank");
        $('#' + item).attr("id", item);
        $('#' + item).click(function()
        {
            var id = $(this).attr('id');
            var itemid = id.split("_end")[0];
            var socialType = itemid.split("_")[1];
            handleSocialBookmarkTrackPost(socialType);
        });
    }
});


function handleSocialBookmarkTrack(socialType)
{
    CallAtlas("mrtwxp_winftpwatchtheadssocialbkmrk_" + socialType);
    CallOmniture(null, null, "Playback_Share_" + socialType);
}

function handleSocialBookmarkTrackPost(socialType)
{
    CallAtlas("mrtwxp_winftpwatchtheadssocialbkmrk_" + socialType);
    CallOmniture(null, null, "PostPlayback_Share_" + socialType);
}