// Uses ClearSpring to write in the share links.
function writeShareProjectLinks(id, name) {
    var launchMenus = [
        [ "",            "",       "Facebook"],
        [ ['myspace'],   "mysBtn", "MySpace"],
        [ ['hi5'],       "hi5Btn", "Hi5"],
        [ ['delicious'], "delBtn", "Delicious"],
        [ ['digg'],      "digBtn", "Digg"],
        [ ['blogger'],   "blgBtn", "Blogger"],
        [ ['typepad'],   "tpdBtn", "TypePad"],
        [ ['xanga'],     "xgaBtn", "Xanga"],
        [ ['twitter'],   "twtBtn", "Twitter"],
        [ ["myspace", "hi5", "friendster", "bebo", "multiply", "blogger", "freewebs",
                "livejournal", "myyearbook", "orkut", "piczo", "tagged", "wordpress",
                "typepad", "vox", "live", "xanga", "mobile", "delicious", "digg", "furl", 
                "googlebookmarks", "livefavorites", "newsvine", "propeller", "rawsugar", "reddit",
                "spurl", "stumbleupon", "technorati", "twitter", "yahoobookmarks", "yahoowidgets", "dashboard",
                "vista", "jscode", "objectcode"], "csmBtn", "More Sites"] 
    ];
    
    var servicesIncludeVal, actionElementVal, serviceName, favIconUrl, htmlOptions;

    // Loop though each share link.
    document.write("<ul>") 
    for (i=0; i < launchMenus.length; i++) {                  
        // Assign the variables for this iteration.
        servicesIncludeVal = launchMenus[i][0];
        actionElementVal   = launchMenus[i][1];
        serviceName        = launchMenus[i][2]; 
               
        if (serviceName=="Facebook") {
            document.write('<li><a href="http://www.facebook.com/share.php?u=' + location.href + '" ' + 
                'onclick="return true;return fbs_click()" target="_blank" alt="Share on Facebook">' + 
                '<img src="http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981" alt="" /></a>')
        } else {
            // The last button has special conditions.
            if (serviceName=="More Sites") {
                favIconUrl = 'http://cdn.clearspring.com/launchpad/static/cs_button_share1.gif';
                htmlOptions = 'border="0"'; // of course, this should be in css
            } else {
                favIconUrl = 'http://www.' + serviceName.toLowerCase() + '.com/favicon.ico';
                htmlOptions = 'width="16" height="16" border="0"';
            } 
            
            // Write the icon into the page using a hyperlink tag.
            document.write('<li><a id="' + actionElementVal + '" href="#" alt="Share on ' + serviceName + '">' +
                '<img src="' + favIconUrl + '" ' + htmlOptions + '></a></li>');
                
            // Link the icon with the appropriate menu.
            $Launchpad.CreateMenu({
                wid:             "476abda21237f37b", 
                widgetName:      name,
                servicesInclude: servicesIncludeVal, 
                actionElement:   actionElementVal,
                bookmarkUrl:     location.href, 
                config:          {bid: id} 
            });
        }
    }
    document.write("</ul>")
}
function changePlayerSize(trigger, size) {
    var $trigger = $(trigger);    
    
    $trigger.addClass('selected').siblings().removeClass('selected');  
     
    $('#main-container').
        removeClass("with-small-player with-medium-player with-large-player with-xlarge-player").
        addClass("with-" + size + '-player'); 
    
    window.scroll(0,125); // scroll down to the player 
}
// Facebook Sharing (from http://www.facebook.com/share_partners.php)
function fbs_click() {
    u=location.href; 
    u+= /\?[^\/]*$/.test(u) ? '&' : '?' ;
    u+= Math.floor(Math.random()*10000 + 1000).toString(); // Add random query string to prevent facebook from caching (says Andrew)
    t=document.title;
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}