﻿// JSLint Config:
/*jslint browser: true */
/*global cc, jQuery, FB, FB_RequireFeatures */

//  
//  Author: Kevin Burkitt
//  Date:   2010-03-31
//  
//  Facebook controller
/*
cc.social.facebook = function() {

    //"private" variables:
    var CC_Username;
    
    function getInviteFBML() {
        var uid = FB.Facebook.apiClient.get_session().uid;
        var fbml = "";
        fbml =  '<fb:fbml>\n' +
			    '<fb:request-form\n' +
                     //Redirect back to this page
						' action="' + document.location + '"\n' +
						' method="POST"\n' +
						' invite="false"\n' +
						' type="' + cc_resx_SITE_NAME + '"\n' +
						' content="You should come and join me on ' + cc_resx_SITE_DOMAIN_TEXT + '' +
						' <fb:req-choice url=\'' + cc_resx_SITE_URL + '?utm_campaign=Facebook_Invite&utm_medium=Vistor_from_Invite_Link&utm_source=Facebook_Invite&utm_content=Invite_Owner_FB_UID_' + uid + '\' label=\'View ' + cc_resx_SITE_NAME + '\' />"\n' +
				  '>\n' +
				   ' <fb:multi-friend-selector\n' +
						' rows="2"\n' +
						' cols="4"\n' +
						' bypass="Cancel"\n' +
						' showborder="false"\n' +
						' actiontext="Invite your friends to connect with you on ' + cc_resx_SITE_NAME + '"/>\n' +
					' </fb:request-form>' +
			' </fb:fbml>';
        return fbml;
    }
    
    function showInviteBoxNow() {
        
        FB_RequireFeatures(["XFBML"], function() {
            FB.Facebook.init(
			        cc_resx_FACEBOOK_API_KEY,
			        "/xd_receiver.htm", 
			        { "ifUserConnected": function() { }, "ifUserNotConnected": function() { } });
        });

        FB.ensureInit(function() {

            FB.Connect.requireSession(function() {

                FB.Facebook.get_sessionWaitable().waitUntilReady(function() {

                    var uid = FB.Facebook.apiClient.get_session().uid;

                    // Update server with connected account
                    // updateAccountFacebookUID();

                    var fbml = getInviteFBML();

                    var dialog = new FB.UI.FBMLPopupDialog("Invite Your Facebook Friends to ' + cc_resx_SITE_DOMAIN_TEXT + '", fbml);

                    dialog.setFBMLContent(fbml);
                    dialog.setContentWidth(650);
                    dialog.setContentHeight(450);
                    dialog.show();


                });

            }, null, true);

        });
    }

    // public methods
    return {
    
        cc.social.facebook.initDone: false,

        showInviteBox: function() {
        
            if (cc.social.facebook.initDone !== true) {
                jQuery.getScript('http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US', function() {
                    cc.social.facebook.initDone = true;
                    showInviteBoxNow();
                });
            }

        }

    };


} ();
*/

/*
publishStreamMessage: function(username) {

    CC_Username = username;

    FB_RequireFeatures(["XFBML"], function() {
FB.Facebook.init(
cc_resx_FACEBOOK_API_KEY
, "/xd_receiver.htm"
, {} );
});

    FB.ensureInit(function() {

        FB.Connect.requireSession(function() {

            FB.Facebook.get_sessionWaitable().waitUntilReady(function() {

                if (CC_Username == 'undefined') {
}
                                
FB.Connect.streamPublish(
''
, { 'name': cc_resx_SITE_NAME, 'href': cc_resx_SITE_URL + CC_Username, 'description': 'Go and Join ' + cc_resx_SITE_NAME + '' }
, [{ "text": "My " + cc_resx_SITE_NAME + " Profile", "href": cc_resx_SITE_URL + CC_Username}]
, null
, 'What do you think?'
, function(post_id, exception) {
// Insert Google tracking to show it was posted (or not, if post_id is null)
}
);

            }, null, true);

        }, null, true);

    });


}
*/

