function init() {				
	FB.init({appId:APP_ID, status: true, cookie: true});
	FB.getLoginStatus(handleLoginStatus);
}

function handleLoginStatus(response) {
	if (response.session) { //Show the SWF
	
		$('#ConnectDemo').append('<h1>You need at least Flash Player 9.0 to view this page.</h1><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>');					
		swfobject.embedSWF("IFrameDemo.swf?<? echo(time()) ?>", "ConnectDemo", "550", "600", "9.0", null, null, null, {name:"ConnectDemo"});
		
	 } else { //ask the user to login
	 
		var params = window.location.toString().slice(window.location.toString().indexOf('?'));										
		top.location = 'https://graph.facebook.com/oauth/authorize?client_id='+APP_ID+'&scope='+PERMS+'&redirect_uri=' + REDIRECT_URI + params;
											
	  }
}
