// Make sure we are on www.hvemvetminst.no and not hvemvetminst.no
if (window.location.host != 'www.hvemvetminst.no') window.location = 'http://www.hvemvetminst.no' + window.location.pathname;

function fbLogin()
{
	FB.login(fbNotifyFlashOfLoginStatus,
	{
		perms: 'publish_stream'
	});
}

function fbNotifyFlashOfLoginStatus(response)
{
	var flashApp = document.getElementById('flashApp');
	flashApp.loginStatusChangedHandler(response.session != null);
}

function fbGetLoginStatus()
{
	FB.getLoginStatus(fbNotifyFlashOfLoginStatus);
}

function fbGetFriends()
{
	FB.api('/me/friends', function(response)
	{
		var flashApp = document.getElementById('flashApp');
		flashApp.getFriendsResponseHandler(response.data);
	});
}

function fbGetMyInfo()
{
	FB.api('/me', function(response)
	{
		var flashApp = document.getElementById('flashApp');
		flashApp.getMyInfoResponseHandler(response);
	});
}

function fbIsLoggedIn()
{
	return FB.getSession() != null;
}

function fbShare()
{
	FB.ui(
			{
				method: 'stream.publish',
				caption: 'Hvor lite kan du om Norge?',
				attachment: {
					name: 'Hvor lite kan du om Norge?',
					description:
						'Norske Vandrerhjem arrangerer en konkurranse der de ønsker å premiere den som kan minst om Norge med tidenes feteste roadtrip!'
					,
					href: 'http://www.hvemvetminst.no'
				}
			}
		);
}
