
/*
 * script part to initialise communication/connection with facebook
 */
	window.fbAsyncInit = function() 
	{
		FB.init({
			appId: '<?php echo $appapikey; ?>',
			status: true,
			cookie: true,
			xfbml: true
		});
	};

	(function() {
		var e  = document.createElement('script');
		e.type = 'text/javascript';
		e.src  = document.location.protocol +
			'//connect.facebook.net/en_US/all.js';
		e.async = true;
		document.getElementById('fb-root').appendChild(e);
	}());

/*
 * Helpers and Flash communication
 */
	function facebookRegister(regType) {
		var  screenX = typeof window.screenX != 'undefined' ? window.screenX : window.screenLeft,
		screenY      = typeof window.screenY != 'undefined' ? window.screenY : window.screenTop,
		outerWidth   = typeof window.outerWidth != 'undefined' ? window.outerWidth : document.body.clientWidth,
		outerHeight  = typeof window.outerHeight != 'undefined' ? window.outerHeight : (document.body.clientHeight - 22),
		width    = 500,
		height   = 270,
		left     = parseInt(screenX + ((outerWidth - width) / 2), 10),
		top      = parseInt(screenY + ((outerHeight - height) / 2.5), 10),
		features = (
			'width=' + width +
			',height=' + height +
			',left=' + left +
			',top=' + top
		);
		if (typeof (regType) == 'undefined') 
			{var regType = '';}
		else
			{regType = '?type='+regType;}
		
		newwindow=window.open('lb/fbconnect/permissions.php'+regType,'Login by facebook',features);
		if(window.focus)
		{
			newwindow.focus();
		}
		return false;
	}
	
	function facebookLogin(){
		facebookRegister();
	}
	
	function getTopWindow()
	{
	  var parentView = document.parentWindow?document.parentWindow:document.defaultView;
	  return parentView.parent;
	}
	
/*	function doLogin(lbId, fbId){
		alert('LbId: ' + lbId + ' - fbId: ' + fbId);
	}
	
	function openRegistration(fbId, userData)
	{
		alert('fbId: ' + fbId + ' - data: ' + userData);
	}*/
