function facebookLogin() {
	FB.Connect.get_status().waitUntilReady(function(status) {
	switch(status) {
		case FB.ConnectState.appNotAuthorized:
		case FB.ConnectState.userNotLoggedIn:
			FB.Connect.requireSession(function() {
				loggedInFb();
			});
			break;
		case FB.ConnectState.connected:
			loggedInFb();
			break;
		}
	});
}			
function loggedInFb() {
	var api = FB.Facebook.apiClient;
	var user = api.get_session().uid;
	var quary = "SELECT email, publish_stream FROM permissions WHERE uid=" + user;
	api.fql_query(quary, function(rows) {
		if (!rows[0].email) {
			FB.Connect.showPermissionDialog("email",function() {
				sendInfo(user,api);
			});
		}
		else {
			sendInfo(user,api);
		}	
	});
}
function sendInfo(user,api) {
	var quary = "SELECT email FROM permissions WHERE uid=" + user;
	api.fql_query(quary, function(rows) {
		if (rows[0].email) {
			var quary = "SELECT first_name, last_name, email, current_location FROM user WHERE uid=" + user;
			api.fql_query(quary, function(rows) {
				if (rows[0].first_name != null) document.SUPPORTER326565.first_name.value = rows[0].first_name;
				if (rows[0].last_name != null) document.SUPPORTER326565.last_name.value = rows[0].last_name;
				if (rows[0].email != null) document.SUPPORTER326565.email_address.value = rows[0].email;
				if (rows[0].current_location != null) {
					if (rows[0].current_location.city != null) document.SUPPORTER326565.city.value = rows[0].current_location.city;
					if (rows[0].current_location.state != null) document.SUPPORTER326565.state.value = stateSwitch(rows[0].current_location.state);
					if (rows[0].current_location.zip != null) document.SUPPORTER326565.zip.value = rows[0].current_location.zip;
				}
				document.SUPPORTER326565.submit();
			});
		}
	});
}
