var swfMinWidth = 700;
var swfWidth = 1200;
var swfHeight = 820;

function start(key){
	FB.init(key, "xd_receiver.htm");
}

function login(){
	FB.Connect.requireSession(getBirthday);
}

function getUserInfo(uid, fields){
	FB.Facebook.apiClient.users_getInfo(uid, fields, function(result, exception){
		try {
			$("#flashcontent")[0].setUserInfo(result[0]);
		} catch(err) {
		}
	}); 
}

function getBirthday(){
	FB.Connect.get_status().waitUntilReady(function(status){
		if (status == FB.ConnectState.connected) getUserInfo(FB.Facebook.apiClient.get_session().uid, ["name, birthday_date, about_me"]);
	});
}

function stopAll(){
	try {
		$("#flashcontent")[0].stopAll();
	} catch(err) {
	}
}

function setSwfSize() {
	windowWidth = $(window).width();
	if (swfMinWidth > windowWidth) windowWidth = swfMinWidth;
	scale = windowWidth / swfWidth;
	wrapHeight = swfHeight * scale;
	$('#swfwrapper').height(wrapHeight);
	$('#wrapper').height(wrapHeight);
};

function loadResize() {
	window.moveTo(screen.availLeft, screen.availTop);
	window.resizeTo(screen.availWidth, screen.availHeight);
	setSwfSize();	
}

net = (document.layers && true);
widgetBuf = (net) ? 0:50

function popWin(url, name, width, height, scroll, resizable) {
	bWidth = (net) ? top.innerWidth:parseInt(top.document.body.clientWidth);
	bHeight = (net) ? top.innerHeight:parseInt(top.document.body.clientHeight);
	bLeft = (net) ? top.screenX:parseInt(top.screenLeft);
	bTop = (net) ? top.screenY:parseInt(top.screenTop);
	scroll = (scroll) ? scroll:"auto"
	resizable = (resizable) ? resizable:"yes"
	if (!bLeft) {
		bLeft = 0;
		bWidth = screen.width;
	}
	if (!bTop) {
		bTop = 0;
		bHeight = screen.height;
	}
	xer = bLeft + ((bWidth/2) - width/2);
	yer = (bTop - widgetBuf) + ((bHeight/2) - height/2);
	if (xer < 2) {
		xer = 2;
	}
	if (xer < 2) {
		xer = 2;
	}
	paramStr = "width=" + width + ",height=" + height + ",screenX=" + xer + ",screenY=" + yer + ",left=" + xer + ",top=" + yer + ",dependent=1,directories=0,location=0,menubar=0,resizable="+resizable+",scrollbars="+scroll+",toolbar=0";
	top[name] = window.open(url, name, paramStr);
	top[name].focus();
}

$(window).resize(function(){
	setSwfSize();	
});


