function isFbMode() {
	if (window.location.href.indexOf("mode=fb") != -1) {
//		alert("isFbMode: true");
		return true;
	}
//	alert("isFbMode: false");
	return false;
}

function fb_init() {
//	alert('fb_init');
//	var api_key = 'bf876aca6a19d42523b2ad090c6fd750'; // youjuke_dev TODO: get key from server... 
	var api_key = '87d6abfd91506fa083307eb3a65cbd83'; // youjuke TODO: get key from server... 
	var channel_path = 'xd_receiver.html'; 
	FB_RequireFeatures(["Connect", "Api", "XFBML"], function(){ 
		FB.Facebook.init(api_key, channel_path); 
		api = FB.Facebook.apiClient;
		api.requireLogin(function(exception) {
			userId = FB.Facebook.apiClient.get_session().uid;
//			alert("user id: " + userId);
			FB.CanvasClient.startTimerToSizeToContent(); 
		});
	});
}

function postToWall(videoId) {    
    var message = 'A cool music video!';
    var attachment = {'name':'Found on YouJuke', 'href':'http://apps.facebook.com/youjuke',  
    	'media':
    	[
            {'type': 'flash', 
    		'swfsrc': 'http://www.youtube.com/v/' + videoId + '&hl=en&fs=1', 
    		'imgsrc': 'http://img.youtube.com/vi/' + videoId + '/default.jpg', 
    		'width': '100', 'height': '80', 
    		'expanded_width': '320', 'expanded_height': '240', 'title':"test_title"}
        ]};
    hidePlayer();
    FB.Connect.streamPublish(message, attachment, null, null, "Leave a comment...", postCallback);
}

function postCallback(post_id, exception) {
	showPlayer();
}





//function init() {
//	alert("init called, posting to stream...");
//	var api = FB.Facebook.apiClient;
//	api.friends_get(null, function(result, exception){
//		alert("test");
//	}); 
//}
//
//function mycallback (post_id, exception) {
//	alert("callback");
//	if (exception) {
//		alert("exception");
//	}
//	if(post_id) { 
//		alert("post id: " + post_id); 
//	} 
//} 