//var api_key = "55856a3b0f5671d71497b5f5d4183dd5";
//var api_key = "e4997cc49567e9b5f738d44a80523d06";
var api_key = "ed0704201ddb6f41330d66c30792cfef";
var app_id = "107349222656360";
var redirectURI = "http://www.ideawork.com/xd_receiver.htm";


function facebook_boot() { FB_RequireFeatures(["Connect"], function() { FB.init(api_key, "/xd_receiver.htm"); FB.Connect.requireSession(); }); }

//FB_RequireFeatures(["Api"], function() {FB.Facebook.init(api_key, "xd_receiver.htm")});

function fbDisplayLikeFrame(on) {
	if(on == "true")
		document.getElementById('likeFrame').style.visibility = "visible";
	else document.getElementById('likeFrame').style.visibility = "hidden";
	document.getElementById('likeFrame').height = "80px";

}


function moveIFrame(x,y) {
	document.getElementById('likeFrame').style.left = x+"px";
	document.getElementById('likeFrame').style.top = y+"px";

}
function fbConnectLogin(){
			//FB.Bootstrap.requireFeatures(["Connect"], startSession);
			//document.getElementById("fblogin").src = "https://graph.facebook.com/oauth/authorize?client_id=137544879619973&redirect_uri=http://dev.ideawork.com/xd_receiver.htm&type=user_agent&display=wap"
			var rnd = Math.floor(Math.random()*11);
			window.open("https://graph.facebook.com/oauth/authorize?client_id="+app_id+"&redirect_uri="+redirectURI+"&type=user_agent&display=popup&scope=publish_stream&x="+rnd,"fb_login","width=430,height=300");

		};
function startSession() {
			FB.Connect.requireSession(sessionHandler);
		};
		
		function sessionHandler(exception) {

			var sessionData = FB.Facebook.apiClient.get_session();

			fb_flashvars = {
				as_swf_name: "main",
				api_key: api_key,
				secret: sessionData.secret,
				session_key: sessionData.session_key,
				uid: sessionData.uid
			};

			swfobject.getObjectById("main").sessionHandler(fb_flashvars);
		};
		
		function fbConnectLogout(){
			FB.Connect.logout();
		};


function confirmFacebookConnection(hash){
			fb_flashvars = {
				as_swf_name: "main",
				session_key: hash
			};
			m.getSWFRef().sessionHandler(fb_flashvars);
//			alert(document.getElementById("main").sessionHandler(fb_flashvars));
			//swfobject.getObjectById("main").sessionHandler(fb_flashvars);
}





