/*
** Grabs FB user data and posts it for an infusionsoft
*/
function yeFBInfusionsoftAdd() {
    FB.getLoginStatus(function(response) {
        // Is the user already logged in?	
        if (response.status === 'connected') {
            // Grab the user data from FB          
            FB.api('/me/interests', function(response){
                var interests = JSON.stringify(response.data);
                
                FB.api('/me/likes', function(response){
                    var likes = JSON.stringify(response.data);
                    
                    FB.api('/me', function(response) {
                        var post_data = {
                            method: 'fb_connect_infusionsoft',
                            data: {
                               email:           response.email,
                               first_name:      response.first_name,
                               last_name:       response.last_name,
                               location:        response.location.name,
                               profile_link:    response.link,
                               username:        response.username,
                               birthday:        response.birthday,
                               interests:       interests,
                               likes:           likes
                            }
                        };

                        // console.log(post_data);
                        // AJAX post it to our ajax script
                        jQuery.post("/wp-content/themes/yogaearth3/ajax_post.php", post_data);
                    });
                });
            });
            
        } else {
            // The user is not logged in yet
        }
	 });
}
