function f03opengraphInit()
{
	// initialize the library with the API key
	FB.init({
				appId	: '124003847623131',
				status	: true,
				cookie	: true,
				xfbml	: true
			});

	// fetch the status on load
	FB.getLoginStatus(handleSessionResponse);
	// what happens if someone logs into facebook
	FB.Event.subscribe('auth.login', handleSessionResponse);

	FB.Event.subscribe('auth.logout', handleSessionResponse);
}

// handle a session response from any of the auth related calls
function handleSessionResponse(response)
{

	// if we dont have a session
	if (!response.session)
	{
		var fb_root = $('fb-root');
		if (fb_root)
		{
			fb_root.fire("facebook:afterlogout");
		}
		return;
	}

	// if we have a session, query for the user's profile picture and name
	FB.api({
				method	: 'fql.query',
				query	: 'SELECT uid, name, first_name, last_name, birthday_date, hometown_location, email FROM user WHERE uid=' + FB.getSession().uid
			}, function(response)
			{

				var fb_root = $('fb-root');
				if (fb_root)
				{
					fb_root.fire("facebook:afterlogin", response[0]);
				}

				// alert ('reposen' + response);
			//				
			// $('fb-root').fire('AfterFacebookLogin', response);
			// if (console)
			// {
			// console.log(response);
			// console.log(FB.getSession());
			// }
			// var memo = {
			// user : response[0]
			// };
			// if (console)
			// {
			// console.log(memo);
			// }

		}
	);
}

document.observe("dom:loaded", f03opengraphInit);
