var flashvars = {};
flashvars.fv_url = 'http://www2.messengerplayground.dk/bedstenetven/';
var params = {};
params.bgcolor = "#ffffff";
params.scale = "noscale";
params.wmode = "opaque";
params.salign = "tl";
var attributes = {};
attributes.id = "flash";
swfobject.embedSWF("SocialPhone.swf", "flash", "100%", "100%", "9.0.0", false, flashvars, params, attributes);

function fbLogin() {
	FB.Bootstrap.requireFeatures(["Connect"], function() {
		FB.Facebook.init($fb_api, "fb_platform/fb_bridge.htm", {"ifUserConnected":onConnected, "ifUserNotConnected":onNotConnected});
	});
}

function onConnected() {
	FB.Connect.showPermissionDialog("publish_stream", function($perms) {
		$.get('inc/fetch.php', {method: 'user'}, function($data) {
			if($('#flash').size() > 0) {$('#flash').get(0).sendUser($data);}
		});
	});
}

function onNotConnected() {
	FB.Connect.requireSession(function() {
		
	});
}

function fbGetTop3() {
	$.get('inc/fetch.php', {method: 'top3'}, function($data) {
		if($('#flash').size() > 0) {$('#flash').get(0).sendTop3($data);}
	});
}

function fbGetFriends() {
	$.get('inc/fetch.php', {method: 'friends'}, function($data) {
		if($('#flash').size() > 0) {$('#flash').get(0).sendFriends($data);}
	});
}

function fbPostOwnWall($target) {
	$.get('inc/fetch.php', {method: 'ownwall', target: $target}, function($data) {
		if($('#flash').size() > 0) {$('#flash').get(0).sendOwnWall($data);}
	});
}

function fbPostFriendWall($target) {
	$.get('inc/fetch.php', {method: 'friendwall', target: $target}, function($data) {
		if($('#flash').size() > 0) {$('#flash').get(0).sendFriendWall($data);}
	});
}

function fbSaveEntry($name, $email, $terms) {
	$.get('inc/fetch.php', {method: 'save', name: $name, email: $email, terms: $terms}, function($data) {
		if($('#flash').size() > 0) {$('#flash').get(0).sendEntry($data);}
	});
}

