c8.Fb = {
		_loggedIn: false,
		_init: false,
		
		Init: function() {
			FB.Bootstrap.requireFeatures(["Connect"], function() {
				c8.Utils.Debug('Facebook Initialization');
				FB.init(c8.Config.Facebook.AppKey, c8.Config.Facebook.XdRcvr);
				c8.Fb._init = true;
			});
		},
		
		Login: function(f) {
			FB.ensureInit(function() {
				FB.Connect.requireSession(function() {
					c8.Fb._init = true;
					if(f && typeof f == 'function') {
						f(); 
					}
				});
			});
		},
		
		Stream: {
			usertext: '',
			actionlink: [],
			attachment: { },
			callback: null,
			
			Publish: function(o) {
				
				this.attachment = {
						'name': o.Title ? o.Title : 'No Title Specified',
						'caption': o.Text ? o.Text : 'No Text Specified',
						media: []
				};
				
				if(o.Description) {
					this.attachment.description = o.Description;
				}
				
				if(o.Image && o.Image.src && o.Image.href) {
						this.attachment.media = [ { type: 'image', src: o.Image.src, href: o.Image.href } ];
				}
				if(o.Link && o.Link.text && o.Link.href) {
					this.actionlink = [ { text: o.Link.text, href: o.Link.href } ];
				}
				if(o.UserText) {
					this.usertext = o.UserText;
				}
				if(o.callback && typeof o.callback == 'function') {
					this.callback = o.callback;
				}
				
				c8.Utils.Debug('Callback to Publish');
				FB.Connect.streamPublish(c8.Fb.Stream.usertext, c8.Fb.Stream.attachment, c8.Fb.Stream.actionlink, null, null, (typeof c8.Fb.Stream.callback == 'function' ? c8.Fb.Stream.callback() : null) );
				c8.Fb.Stream.usertext = '';
				c8.Fb.Stream.attachment = { };
				c8.Fb.Stream.actionlinks = [];
				c8.Fb.Stream.callback = null;
			}
		}
}