
(function () {

	window.FBIntegrate = function () {}

	var self = FBIntegrate;

	FBIntegrate.submit = function () {

		Utils.getElement( "_submit" ).disabled = true;

		FBAuth.login(

			function ( response ) {

				if ( response.status ) {

					FB.api(

						"/me",
						"get",
						{},
						function ( response ) {

							if ( !response || response.error ) {

							}
							else {

								self.integrate( response.id, response.email );
							}
						}
					);
				}
			},
			{
				"scope":"read_stream,publish_stream,email"
			}
		);
	}

	FBIntegrate.integrate = function ( id, email ) {

		Utils.getElement( "_facebook_id" ).value = id;
		Utils.getElement( "_emailaddress" ).value = email;

		Utils.getElement( "_integrate" ).submit();
	}

})();



