window.fbAsyncInit = function() {
	FB.init({
		appId: '118362056387',
		cookie: true,
		xfbml: true,
		oauth: true
	});
	FB.Event.subscribe('auth.login', function(response) {
		window.location.reload();
	});
	FB.Event.subscribe('auth.logout', function(response) {
		window.location.reload();
	});
	FB.getLoginStatus(function(response) {
		 if (response.status === 'connected') {
			// the user is logged in and connected to your
			// app, and response.authResponse supplies
			// the user's ID, a valid access token, a signed
			// request, and the time the access token 
			// and signed request each expire
			var uid = response.authResponse.userID;
			var accessToken = response.authResponse.accessToken;
			$('#fb-connect').hide();
			$('#fb-image').show();
		} else if (response.status === 'not_authorized') {
			// the user is logged in to Facebook, 
			//but not connected to the app
			$('#fb-connect').hide();
			$('#fb-image').show();
		} else {
			// the user isn't even logged in to Facebook.
			$('#fb-connect').show();
			$('#fb-image').hide();
		}
	});
};
(function() {
	var e = document.createElement('script'); e.async = true;
	e.src = document.location.protocol +
		'//connect.facebook.net/fr_FR/all.js';
	document.getElementById('fb-root').appendChild(e);
}());

function facebook_onlogin() {
	FB.login(function(response) {
		if (response.authResponse) {
			console.log('Welcome!  Fetching your information.... ');
			FB.api('/me', function(response) {
				$.post('facebook.php?authorize=1', { fb_uid:response.id }, function(data) {
					console.log('Good to see you, ' + response.name + '.');
				});
			});
		} else {
			console.log('User cancelled login or did not fully authorize.');
		}
	}, {scope: 'manage_pages,email,publish_stream,offline_access,publish_stream'});
}

$(function() {
	
});
	  
	 /*
function onConnected(user_id) {
	$('#fb-connect').hide();
	$('#fb-image').show();
	setTimeout('getProfilePic()',2000);
}

function onNotConnected() {
	$('#fb-connect').show();
	$('#fb-image').hide();
}

function facebook_onlogin() {
	$.post('facebook.php?authorize=1', { fb_uid:FB.Facebook.apiClient.get_session().uid }, function(data) {
		FB.Connect.showPermissionDialog('status_update,offline_access,publish_stream');
	});
} 

function getProfilePic() {
	var fbml = $('#fb-image').html();
	var img_url = fbml.substr(fbml.indexOf('img src')+9,fbml.indexOf('" alt="')-fbml.indexOf('img src')-9);
	
	var options = { path: '/', expires: 1 };
	$.cookie('djpod_fbpic', img_url, options);
}

function facebook_onload(already_logged_into_facebook) {	
  FB.ensureInit(function() {
      FB.Facebook.get_sessionState().waitUntilReady(function(session) {
		  var is_now_logged_into_facebook = session ? true : false;
          if (is_now_logged_into_facebook == already_logged_into_facebook) {
            return;
          }
          refresh_page();
        });
    });
}

function refresh_page() {
  window.location = String(document.location);
}
*/
