﻿// JSLint Config:
/*jslint browser: true */
/*global cc, jQuery */

//  
//  Author: Kevin Burkitt
//  Date:   2010-02-25
//  
//  Social Network connections/handlers
//
cc.social = function() {

    return {
        facebookShare: function() {
            var u = encodeURIComponent(location.href);
            var t = encodeURIComponent(cc.helpers.getPageTitle());
            window.open('http://www.facebook.com/sharer.php?u=' + u + '&t=' + t, 'sharer', 'toolbar=0,status=0,width=626,height=436');
            return false;
        },

        beboShare: function(url, title) {
            var u = encodeURIComponent(location.href);
            var t = encodeURIComponent(cc.helpers.getPageTitle());
            if (typeof url !== 'undefined' && url !== '') {
                u = encodeURIComponent(url);
            }
            if (typeof title !== 'undefined' && title !== '') {
                t = encodeURIComponent(title);
            }
            window.open('http://www.bebo.com/c/share?Url=' + u + '&Title=' + t);
            return false;
        },

        twitterShare: function() {
            var u = encodeURIComponent(location.href);
            var t = encodeURIComponent(cc.helpers.getPageTitle());
            window.open('http://twitter.com/home?status=' + t + ':+' + encodeURIComponent(u));
            return false;
        },

        mySpaceShare: function() {
            var u = location.href;
            var title = cc.helpers.getPageTitle();
            var t = encodeURIComponent(cc.helpers.getPageTitle());

            var targetUrl = 'http://www.myspace.com/index.cfm?fuseaction=postto&';
            targetUrl += 't=' + t;
            targetUrl += '&c=' + encodeURIComponent('<a href="' + u + '" title="' + title + '">' + title + '</a>');
            targetUrl += '&u=' + encodeURIComponent('http://myspace.com/') + '&l=1';

            window.open(targetUrl);
            return false;
        }
    };

} ();

