
function closeWindow() {
	if (window.opener && !window.opener.closed) {
		window.close();
	}
	
	return false;
}


$(window).unload(function() {
	if(window.opener) {
		window.opener.location = window.opener.location.href;
	}
});


function checkHeight() {
	//console.log(window.innerHeight, document.height);
	if(window.innerHeight < document.height) {
		setSize();
		setTimeout('checkHeight()', 500);
	}
}

function setSize() {	
	var height = $("body").outerHeight();
	
	var canvasHeight = height+10;
	FB.Canvas.setSize({ width: 520, height: canvasHeight});
}



$(document).ready(function() {

	window.fbAsyncInit = function() {
    	FB.init({
    		appId: appId, 
    		status: true, 
    		cookie: true, 
    		xfbml: true
    	});
    	    
		setSize(); 
		
		
		
		$('img').load(function() {
			setSize();
		});
			
		setSize();
		setTimeout('checkHeight()', 1000); 
		
	};
	
	if(lang == '' || lang == undefined) {
		lang = 'de_DE';		
	}
	
	(function() {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol + '//connect.facebook.net/'+lang+'/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    }());
    
});
