// friend target id - used to target a specific id, that is also a friend
var friendID;

// initialize the library with the API key
FB.init({ apiKey: "aed0e89b20156d8e78dca4abb90d40ee" }, "xd_receiver.htm" );

// fetch the status on load
FB.getLoginStatus(handleSessionResponse);

FB.XFBML.parse();

// handle a session response from any of the auth related calls
function handleSessionResponse(response) 
{
	// if we dont have a session, just hide the user info
	if (!response.session) 
	{
		//clearDisplay();
		return;
	}

	// if we have a session, query for the user's profile picture and name
	FB.api(
		{
			method: 'fql.query',
			query: 'SELECT name, pic FROM profile WHERE id=' + FB.getSession().uid
		},
		function( response ) 
		{
			var user = response[0];
		 // $('#fbuser').html('<img src="' + user.pic_small + '">&nbsp;' + user.name).show('fast');
			var _html = "<img src=\"" + user.pic + "\" /><br/>Welcome, " + user.name;
			$('#fbuser').html( _html ).show('fast');
		}
	);
}

// no user, clear display
function clearDisplay() 
{
	$('#fbuser').hide('fast');
}
