
/**
 * fb_invite
 * 
 * Invite users
 *
 * @access public
 * @return void
 */
function fb_invite() {
  session = FB.getAuthResponse();
  FB.ui({
    method: 'apprequests',
//      filters: 'app_non_users',
    data: session['uid']?session['uid']:'',
    message: 'Check this out! Bet on Sports Free and Win Real Cash @ FreeSportsBet.com'
  });
}

/**
 * fb_connect 
 *
 * Connect user to facebook 
 * asking user for FB permmisions then
 * redirecting to PHP page to take action
 * with validated user
 *
 * @access public
 * @return void
 */
function fb_connect() {
  FB.login(function(response) {
    if (response.authResponse) {
      document.location = '/facebook/signin';
    } else {
      console.log('user is not logged in');
    }
  }, {scope: 'email,user_birthday'});
}

/**
  * fb_stream_publish 
  * 
  * Produce a stream publish pop-up
  *
  * @access public
  * @return void
  */
function fb_stream_publish() {
  FB.ui(
    {
      method: 'feed',
      name: 'Freesportsbet.com',
      link: 'http://www.freesportsbet.com',
      caption: 'Bet on sports for free.',
      description: 'Risk nothing. Win real cash.'
    },
    function(response) {
      if (response && response.post_id) {
        alert('Published!');
      }
    }
  );
}

function fb_login() {
  if(!FB.getAuthResponse()) {
    FB.login();
    return false;
  }
  return true;
}




